Solved

trivial thing

Posted on 1998-12-11
1
126 Views
Last Modified: 2010-05-03
how to use odbc api in the visual basic ?
0
Comment
Question by:rayau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

726 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