Can i perform a connection to sql server 2005 on a hook using ADO?
How can i do that cause im trying without any result
this is my code
Dim Value_Need As String
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New Connection
Set rst = New Recordset
cnn.Open "Provider=SQLNCLI;Server=ServerRMS;Database=RMSSampleDB;Uid=sa; Pwd=P@$$W0RD;", "sa", "P@$$W0RD"
' abrir el recordset indicando la tabla a la que queremos acceder
rst.Open "SELECT Password FROM Cashier WHERE Number = " & "'" & LastCashier & "'", cnn, adOpenDynamic, adLockOptimistic
' Asignar los nombres de los campos al combo
If Not rst.EOF And Not rst.BOF Then
rst.MoveFirst
Value_Need = rst.Fields("Password")
Else
Value_Need = ""
End If
' Cerrar el recordset y la conexión
rst.Close
cnn.Close
but getting error looks like i dont have register the dll for ADO connection but i verify and i have the same version.
If i try this code on a winform or class works fine but in the hook cant make work.
*This post is locked for comments
I see that your last post is a solution that will work. It's called late binding.
You can also use the method in your first post, you will just need to add a reference to "Microsoft ActiveX Data Objects", file name ADODB.dll
Thank you.
TimB
i have solution sorry for post but if some else have the same error here is my solution
just change this lines.
Dim cnn
Dim rst
Set cnn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB.Recordset")
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156