Abbas Hayali
asked on
macro
I created an provider driver for SQl server using the user login for authentication , and tested successfully . But when my vb code tries to access the filedsn I created it gives me an error , saying Runtime error '-2147217843 (80040e4d)',
the code is :
Sub main()
Dim Db As ADODB.Connection
Dim RS As ADODB.Recordset
Dim CMD As ADODB.Command
Set Db = New ADODB.Connection
Set RS = New ADODB.Recordset
Set CMD = New ADODB.Command
Db.CursorLocation = adUseClient
Db.Open "Provider=SQLNCLI11;server =server-pc ;Database= IFS_803_13 960820;Use rId=faraus er;Passwor d=tycedar"
CMD.ActiveConnection = Db
CMD.CommandType = adCmdStoredProc
CMD.CommandText = "__GASKARTPEYMAN__"
CMD.Parameters.Append CMD.CreateParameter("@PNO" , adInteger, adParamInput, 10, 31529)
Set RS = CMD.Execute
End Sub
the code is :
Sub main()
Dim Db As ADODB.Connection
Dim RS As ADODB.Recordset
Dim CMD As ADODB.Command
Set Db = New ADODB.Connection
Set RS = New ADODB.Recordset
Set CMD = New ADODB.Command
Db.CursorLocation = adUseClient
Db.Open "Provider=SQLNCLI11;server
CMD.ActiveConnection = Db
CMD.CommandType = adCmdStoredProc
CMD.CommandText = "__GASKARTPEYMAN__"
CMD.Parameters.Append CMD.CreateParameter("@PNO"
Set RS = CMD.Execute
End Sub
ASKER
Thanks
but this way dose not work because the error is on this line:
Db.Open "Provider=SQLNCLI11;server =server-pc ;Database= IFS_803_13 960820;Use rId=faraus er;Passwor d=tycedar"
but this way dose not work because the error is on this line:
Db.Open "Provider=SQLNCLI11;server
Oh, I believe you do not have the correct connection string in this case. The connection string that you have is a DSN-less connection to a database that is hosted on an instance of SQL Server.
So, if your fileDSN is named "myfileDSN", you need:
So, if your fileDSN is named "myfileDSN", you need:
Db.Open "fileDSN=myfileDSN"
Db.Open "Provider=SQLNCLI11;server =server-pc ;Database= IFS_803_13 960820;Use rId=faraus er;Passwor d=tycedar"
Please check if the password is correct.
Please check if the password is correct.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
i.e. use:
Open in new window
instead of:
Open in new window