Create an ADO connection to the database

by Linda Quinn

Close Window


Public gConn As New ADODB.Connection

Public Function DataOpen() As Boolean
On Error GoTo open_EH

gConn.CursorLocation = adUseClient
gConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;_
Data Source=C:\Products\Products.mdb;"
gConn.Mode = adModeReadWrite
gConn.Open

DataOpen = TRUE

open_EH:
Call ErrorHandler(gConn)
DataOpen = FALSE
Exit Function
End Function


Public Sub ErrorHandler(gConn As Connection)
Dim oErr As Error
Dim strMsg As String

For Each oErr in gConn.Errors

strMsg = strMsg & "Error #: & oErr.Number & vbCrLf
strMsg = strMsg & "Description: " & oErr.Description & vbCrLf
strMsg = strMsg & "Source: " & oErr.Source & vbCrLf
Next

MsgBox strMsg

End Sub






=================================================================
This content was created by Linda Quinn of LQNet.

See http://www.lqnet.com for a great collection of articles on this and other topics.

=================================================================
Copyright © 2006-2008, LQ Systems,Inc. All rights reserved.


====================================================================
Want an expert to help with your project?    LQ Systems, Inc.   Business Solutions
====================================================================