Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC Connection

Status
Not open for further replies.

rry2k

Programmer
Joined
Jun 28, 2001
Messages
678
Location
US
I have had someone ask me about making ODBC connections for an Access Database. Would this indicate that they are using something like VB for a front end? Otherwise it doesn't make sense to me because why not just use properties to connect if it's a straight db application?
I'm not getting what there wanting so please include an example if you would.

Thanks alot for the help,
Russ
 
I think that this individual was referring to using an ODBC connection in conjunction with an ADO connection string to access data on a server without using linked tables or JET SQL. Here is an example of what I'm talking about(connects to a Sybase back-end).
Code:
Dim strSQL As String
Dim rsQuery As ADODB.Recordset
strSQL = *Put your SQL statement here*
Set rsQuery = New ADODB.Recordset
rsQuery.Open strSQL, conSybase
If rsQuery.RecordCount > 0 Then
   Set Forms("frmUserData").Recordset = rsQuery
   [Forms]![frmUserData]![txtID].SetFocus
'***Global function used to connect to back-end
Public Function conSybase() As ADODB.Connection
Set conSybase = New ADODB.Connection
    With conSybase
        .ConnectionString = "DSN=PACM_PROD;uid=metadata_admin;pwd=newpass;IS=SET ANSINULL OFF"
        .ConnectionTimeout = 300
        .CommandTimeout = 300
        .CursorLocation = adUseClient
        Call .Errors.Clear
        Call .Open
    End With
End Function
Hope this helps
 
Thanks that makes sense. I'm sure your probably right.
 
You can also use the Windows ODBC administrator to create data sources for connection to just about any database. You must have the correct driver loaded in the odbc administrator to be successful with this approach. I use it all the time. Also involves mapping drives.
 
Great,

Thank you both for the help. So if I'm undestanding this correctly, when someone talks about odbc in this context they are talking about a DSN?
 
ODBC stand for Open Data Base Connectivity. DSN = Data Source Name. For odbc to properly connect and keep a data base open, you must have a data source. So, yes, DSN is directly related to OBDC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top