Solved

trivial thing

Posted on 1998-12-11
1
124 Views
Last Modified: 2010-05-03
how to use odbc api in the visual basic ?
0
Comment
Question by:rayau
1 Comment
 
LVL 1

Accepted Solution

by:
bear454 earned 50 total points
ID: 1449642
Sub OpenConnectionX()

Dim wrkODBC As Workspace
Dim conPubs As Connection
Dim conPubs2 As Connection
Dim conPubs3 As Connection
Dim conLoop As Connection

' Create ODBCDirect Workspace object.
Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
"admin", "", dbUseODBC)

' Open Connection object using supplied information in
' the connect string. If this information were
' insufficient, you could trap for an error rather than
' go to an ODBC Driver Manager dialog box.

MsgBox "Opening Connection1..."
Set conPubs = wrkODBC.OpenConnection("Connection1", _
dbDriverNoPrompt, , _
"ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")

' Open read-only Connection object based on information
' you enter in the ODBC Driver Manager dialog box.
MsgBox "Opening Connection2..."
Set conPubs2 = wrkODBC.OpenConnection("Connection2", _
dbDriverPrompt, True, "ODBC;DSN=Publishers;")

' Open read-only Connection object by entering only the

' missing information in the ODBC Driver Manager dialog
' box.
MsgBox "Opening Connection3..."
Set conPubs3 = wrkODBC.OpenConnection("Connection3", _
dbDriverCompleteRequired, True, _
"ODBC;DATABASE=pubs;DSN=Publishers;")

' Enumerate the Connections collection.
For Each conLoop In wrkODBC.Connections
Debug.Print "Connection properties for " & _
conLoop.Name & ":"

With conLoop
' Print property values by explicitly calling each

' Property object; the Connection object does not
' support a Properties collection.
Debug.Print "    Connect = " & .Connect
' Property actually returns a Database object.
Debug.Print "    Database[.Name] = " & _
Database.Name
Debug.Print "    Name = " & .Name
Debug.Print "    QueryTimeout = " & .QueryTimeout
Debug.Print "    RecordsAffected = " & _
RecordsAffected
Debug.Print "    StillExecuting = " & _

StillExecuting
Debug.Print "    Transactions = " & .Transactions
Debug.Print "    Updatable = " & .Updatable
End With

Next conLoop

conPubs.Close
conPubs2.Close
conPubs3.Close
wrkODBC.Close

End Sub


It creates a directworkspace and then opens an connection to a specified database.

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DIR issue 7 54
VBA error replacing data 6 39
String manipulation in Visual Basic 7 62
Hide vba in gp 7 93
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question