General discussion

Locked

ODBC problem

By hherron ·
Can anyone help me find an answer to this ODBC problem ?

In a Visual Basic application, I am trying to find out the database name of a Data Source. I have an ODBC data source which points to an MS Access 2000 database. In the ODBC administrator, if you click on a DSN, and then click the Configure button, a dialog is displayed and the current physical database path (i.e.; C:\Data\MyDataBase.mdb) is displayed. I need to know the physical database name given that I know the data source name. Inside my Visual Basic application, I call SQLDataSources to get the data source names on my machine, but this does not provide the Physical Database associated with this data source. Somehow, the ODBC administrator knows the physical name, but I can?t figure out how to get this information.

I thought I should use SQLGetInfo using the SQL_DATABASE_NAME InfoType, but cannot get this to work. My intention is to eventually use SQLConfigDataSource to change a physical mapping for a data source to a new physical databa

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

ODBC problem

by keith.hall1 In reply to ODBC problem

I don't know how critical your app will be or whether you still intend to use an access 2000 database later or SQL server.
An alternative that I have worked with in the past is ADO.
You can create a connection on the fly like this:
Private WithEvents adoPrimaryRS As Recordset
Private db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.00;Data Source=E:\Projects\data.mdb;"
Set adoPrimaryRS = New RecordsetadoPrimaryRS.Open "select cat,delivery,description,href,image,price,product,vat from tblProducts", db, adOpenStatic, adLockOptimistic

Since the location/name of the database is a string it can give you the option of changing the database to another location/name later.
Ah - you also need to learn the ADO methods etc.

Regards

Keith Hall

Collapse -

ODBC problem

by hherron In reply to ODBC problem

The question was auto-closed by TechRepublic

Collapse -

ODBC problem

by stefanw In reply to ODBC problem

Or, you could just read the registry setting for the odbc data source.
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI

Collapse -

ODBC problem

by hherron In reply to ODBC problem

The question was auto-closed by TechRepublic

Collapse -

ODBC problem

by hherron In reply to ODBC problem

This question was auto closed due to inactivity

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums