Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Connection - proving SQL login and password

Status
Not open for further replies.

cupofteawithsugar

Programmer
Apr 21, 2006
2
GB
Hi All,

I have Windows Authenication for my users using the ADP project which works fine for all tasks except one.

I have a DTS package and for this I have to change the ADP connection to an SQL login. I would then in the VB code like to execute the DTS package. I need this to be done all behind the form so the users sees nothing.

I found this code on the forum


On Error GoTo ErrHandler
Dim oConn As ADODB.Connection
Dim oComm As ADODB.Command
Set oConn = New ADODB.Connection
Set oComm = New ADODB.Command
'====
oConn.ConnectionString = "Provider=Microsoft.Access.OLEDB.10.0;;Data Source=servername;Persist Security Info=True;" _
& "Initial Catalog=Database;Trusted_Connection=Yes;Data Provider=SQLOLEDB.1"
can you change this to have sa password and username?
oConn.Open
Set oComm.ActiveConnection = oConn
oComm.CommandType = adCmdUnknown
oComm.CommandText = "DTSpacakgename" would this work?
oComm.Execute


Exit Sub
ErrHandler:
Dim er As ADODB.Error
Debug.Print " In Error Handler "; err.Description
For Each er In cn.Errors
Debug.Print "err num = "; err.Number
Debug.Print "err desc = "; err.Description
Debug.Print "err source = "; err.Source
Next

Any ideas or a point in the right direction would be great.

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top