Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto setup ODBC Data Source during program setup

Status
Not open for further replies.

ChrisN

Programmer
Jul 9, 2001
59
GB
Is it possible to create an ODBC datasource when installing a program that requires one, or do you have to do it manually afterwards?
 
Hello

Yes it is.

How you do it depends on the tool you are using to create your installations.
 
OK, I am using the Visual Basic 6 Package and Deployment Wizard.

Can I do it?
 
I don't think you can do it from the Package and Deployment wizard.

You can either write a small program to create the ODBC datasource using API calls (lookup MSDN on SQLConfigDataSource) and call the program from the wizard.
eg.
SQLConfigDataSource( NULL,ODBC_ADD_DSN, "Excel File(*.xls)",
"DSN=New Excel Data Source\0"
"Description=New Excel Data Source\0"
"FileType=Excel\0"
"DataDirectory=C:\\EXCELDIR\0"
"MaxScanRows=20\0");


Or

You could create a registry file which inserts the correct registry entries for your ODBC connection. and run the registry file.

Hope this helps,

Chris Dukes
 
I also don't think you can do it from the Package and Deployment wizard.

An extension to Chris's point;
You can create a file dsn which you can then manipulate using INI file functionality to ensure the database location is correct.
 
The database is on a SQL7 server, does this have an impact on the ability to use a file DSN?

Looks like I might have to look into using the SQLConfigDataSource API, although I have never done anything like this before!!
 
No,
See attached file DSN for Sql Server, as long as you get the provider right

[oledb]
; Everything after this line is an OLE DB initstring
Provider=SQLOLEDB.1;Password=auxprd01sys;Persist Security Info=True;User ID=auxprd01;Initial Catalog=AuxPrd01;Data Source=NAMTLCOSTCO;Application Name=PBSMatch


Chris Dukes
 
No, it makes no odds what and where the database is as long as you know where it is (to point the DSN at it).

I would suggest creating a file dsn through your ODBC manager and having a look at the structure of the file since it correlates closely to the API call.
And you will get all the proper names for drivers etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top