Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a DSN in code.
Message
 
To
04/02/2008 12:26:07
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01289107
Message ID:
01289130
Views:
17
>>>I am looking for a way to create a system DSN via code. We are migrating to SQL server. Currently, we will be pulling static history from SQL server for reports. To aid in the upgrading, I am looking for a way to generate the ODBC System DSN.
>>
>>If it is ODBC why not use SQLSTRINGCONNECT()?
>
>That was my first thing I looked at. But I can connect via DNS, but not through a connection string directly using the same parameters. Do know of anything that could be different that I am missing?

NO WAY!
If you could connect with DSN you should connect with SQLSTRINGCONNECT() (AFAIK)


BTW here what I found (http://www.thescarms.com/vbasic/CreateDSN.aspx):

ODBC entries are located in the registry in two spots. Both are under the HKEY_Local_Machine\Software\ODBC key. The first is found in the ODBC Data Sources subkey.

The ODBC Data Sources subkey contains a single string value. The name of this value is simply the name you want to assign to the DSN. This is the name displayed in the ODBC Data Administrator window. The value is the name of the associated driver, "Microsoft Access Driver (*.mdb)" in this case.

The second set of registry entries go in the ODBC.INI subkey. Under this key you must create a subkey with the same name used in the previous step. In my sample I called it "MS Access DSN". This is where you write values for the path to the database and driver, the description used for the DSN and the security info such as user ID and password.

With MS Access, you need to create a few keys underneath this key as shown in the program. In general, the keys and values required will differ with the database you are trying to connect to.

If you want your new DSN to appear in the ODBC Data Source Administrator window you must make one final entry. This entry goes in the ODBC.INI file found in your Windows folder.

First you must create a new section. The section name is the same as that of your DSN, example: "[MS Access DSN]". Finally you create a "Driver32" item whose value is the path to the database driver. That's it.

They talk about Access, but I am sure you could handle all. :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform