Converting an RDO to ADO

Hi!! I was wondering if someone could help me with this. I want to convert the following code to use ADO instead of RDO..

Public Sub Open_SQLServer(strDatabase)

Set en = rdoEnvironments(0)

With rdoEngine
.rdoDefaultLoginTimeout = 20
.rdoDefaultCursorDriver = rdUseOdbc
.rdoDefaultUser = "xxxx"
.rdoDefaultPassword = ""
End With

Set en = rdoEnvironments(0)
Set cn = en.OpenConnection(dsName:="", _
Prompt:=rdDriverNoPrompt, _
Connect:="uid=xxx;pwd=xxxxxx;driver={SQL Server};" _
& "server=Jackdb;database=" & strDatabase & ";")
Debug.Print cn.Connect


End Sub

I would just use the new server info, however, it would be alot less code to write if I can just use ADO.

Comments

  • : Hi!! I was wondering if someone could help me with this. I want to convert the following code to use ADO instead of RDO..
    :
    : Public Sub Open_SQLServer(strDatabase)
    :
    : Set en = rdoEnvironments(0)
    :
    : With rdoEngine
    : .rdoDefaultLoginTimeout = 20
    : .rdoDefaultCursorDriver = rdUseOdbc
    : .rdoDefaultUser = "xxxx"
    : .rdoDefaultPassword = ""
    : End With
    :
    : Set en = rdoEnvironments(0)
    : Set cn = en.OpenConnection(dsName:="", _
    : Prompt:=rdDriverNoPrompt, _
    : Connect:="uid=xxx;pwd=xxxxxx;driver={SQL Server};" _
    : & "server=Jackdb;database=" & strDatabase & ";")
    : Debug.Print cn.Connect
    :
    :
    : End Sub
    :
    : I would just use the new server info, however, it would be alot less code to write if I can just use ADO.
    :
    That is true :)

    [code]
    Dim MyConnection as ADODB.Connection
    set MyConnection = new ADODB.Connection
    MyConnection.Open("your connection string goes here...")
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion