Monday, March 12, 2012

how make public sql connection

hi,
i want to make a sql connection for a simple application
but i want to use this same connection in the application i have 10 forms in
application so i want in all forms.
after i make setup i can i should change the server name and password.
so if this possible please tell me about this in details.
thanks.
mitesh
This connection works well for me:
Sub InsertData()
Dim oConn As Object
Dim sSQL As String
Application.ScreenUpdating = False
Set wsSheet = ActiveWorkbook.Sheets("Product Tracking")
Set oConn = CreateObject("ADODB.Connection")
oConn.Open = "Provider=sqloledb;" & _
"Data Source=xx.x.xx.xx;" & _
"Initial Catalog=xxx_xxx;" & _
"User Id=xxxx;" & _
"Password=xxxx"
sSQL = "INSERT INTO Upload_Specific " & _
"([Location], [Product Type], [Quantity], [Product Name], [Style],
[Features]) " & _
" VALUES ('" & Range("A2").Value & "', '" & Range("B2").Value & "', '" &
Range("C2").Value & "', '" & Range("D2").Value & "', '" & Range("E2").Value
& "', '" & _
Range("F2").Value & "')"
oConn.Execute sSQL
oConn.Close
Set oConn = Nothing
End Sub
HTH
"mitesh" <mitesh@.discussions.microsoft.com> wrote in message
news:F5513C08-228E-4AE5-A5CC-A8AA574DA6DB@.microsoft.com...
> hi,
> i want to make a sql connection for a simple application
> but i want to use this same connection in the application i have 10 forms
> in
> application so i want in all forms.
> after i make setup i can i should change the server name and password.
> so if this possible please tell me about this in details.
> thanks.
> mitesh

No comments:

Post a Comment