How do I create an ODBC connection from VB? 
Author Message
 How do I create an ODBC connection from VB?
Hi

Does anyone know how to create an odbc connection to SQL Server from VB.

Has anyone done this before?

I have tried the RegisterDatabase method of the DBEngine object.
However I always get odbc call failed

All help appreciated

--

scholl.com

Sent via Deja.com http://www.***.com/
Share what you know. Learn what you don't.



Tue, 25 Dec 2001 03:00:00 GMT
 How do I create an ODBC connection from VB?

First declare a var for you connection ie;

Public dbRDO As rdoConnection

The following procedure will establish your connection;

Public Function RDOConnect(ByVal sDSN As String) As Boolean

    On Error GoTo eh_RDOConnect

    Set dbRDO = Nothing
    Set dbRDO = New rdoConnection
    dbRDO.Connect = "DSN=" & sDSN & ";"
    dbRDO.EstablishConnection

    RDOConnect = True

    Exit Function

eh_RDOConnect:
    If Err = 40059 Then
        ' User Hit cancel... ignore
    End If

End Function

You must supply 'RDOConnect' with the name of a valid DSN.

Kent E. Salsby

Quote:

>Hi

>Does anyone know how to create an odbc connection to SQL Server from VB.

>Has anyone done this before?

>I have tried the RegisterDatabase method of the DBEngine object.
>However I always get odbc call failed

>All help appreciated

>--

>scholl.com

>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.



Wed, 26 Dec 2001 03:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. create ODBC connection from VB

2. How to create a data connection VB.net

3. Newbie: how to create a DSN-less connection thru VB

4. Problem creating an SQL Server trigger from ADO connection in VB

5. Creating a connection + query in Access2k (in VB)

6. Creating a connection + query in Access2k (in VB)

7. Upgrading VB 3\ODBC 2.0 to VB 5.0\ODBC 2.5 with MS SQL 6.5 database

8. Create simplest JDBC-ODBC connection in Windows 2000

9. Help Creating a Dynamic ODBC connection

10. Creating ODBC connection to SQL Server 6.5 with VB4

11. Creating the ODBC Connection

12. ODBC Connection broken when Index is created


 
Powered by phpBB® Forum Software