Skip to main content

Notifications

Microsoft Dynamics RMS (Archived)

Hook and Connection to SQL

Posted on by Microsoft Employee

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

  • Suggested answer
    TimB Profile Picture
    TimB 1,175 on at
    Re: Hook and Connection to SQL

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Hook and Connection to SQL

    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")

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans