Click to See Complete Forum and Search --> : How to add an ODBC data source during setup?


chiyli
November 3rd, 1999, 08:24 AM
I use VB6 and MS Access. I want to add an ODBC data source during setup or the first time the program runs. I know I can do it manually by going to Start-Settings-COntrol Panel-ODBC Data Sources, but I want it achieved in programs. Does anybody know the API to do this in VB or InstallShield? Thank you very mcuh!

Lothar Haensler
November 3rd, 1999, 08:30 AM
if you use a FILE DSN instead of a user or system DSN you won't need to use an API or access the Control panel.
Simply create a FILE DSN on your development machine and include it in your setup.

chiyli
November 3rd, 1999, 08:35 AM
Do you mean that setup will automatically add that DSN into ODBC Data Sources if that DSN does not exist in user's machine?

Lothar Haensler
November 3rd, 1999, 08:38 AM
kind of.
As far as FileDSNs are concerned, the control panel applet will look in a certain folder to see if there are any file DSNs (don't remember the exact folder path).
Anyway, you can place yoUR FILEDSNFile anywhere you want, provided that you specify the path to that file DSN file in your connectionstring.

chiyli
November 3rd, 1999, 09:06 AM
I looked Help and it says I can create a FILE DSN by right-click the database project I want to add a data connection to, and then select Add Data Connection. But I can not find it.

My problem is that I need to tell Crystal Report a DSN which is in my development machine, but I want to make it appear in user's machine as well.

Lothar Haensler
November 3rd, 1999, 09:09 AM
Too bad, I don't really (want to) know much about Crystal Reports.
You might want to take a look at the RegisterDatabase method in DAO. It allows you to programmatically create the DSN information.

chiyli
November 3rd, 1999, 09:30 AM
Thank you very much! That is what I need!