tags:

views:

410

answers:

2

I'm not trying to create an ODBC connection to be used in my application. I am working with another scripting language (I have no choice) that uses a local ODBC connection defined in odbcad32 (the Microsoft ODBC Source Administrator). I want to programmatically change the server in in odbcad32, and then call the script to do what it does, using the new information.

A: 

Sounds like you want a work queue from your language of choice via your DBMS of choice, and have C# code run as a result. If you are using a language (didn't specify) on windows, or elsewhere that supports a Message Queue system, this may be your best bet. The short answer is, yes you can maintain a persistent connection. With MS-SQL 2005+ you can even create embedded code that is written in C# to respond to events, and functions.

If you would like a more specific answer, it would help to ask a more specific question.

Tracker1
Way off. I just want to add an odbc connection to odbcad32.
scottm
+1  A: 

I'm not sure if this is the best way, but you can simply create a .dsn file in the directory where your File Data Sources are kept. In my case that is C:\Program Files\Common Files\ODBC\Data Sources.

The files are just text files that look something like this:

[ODBC]
DRIVER=SQL Server
UID=myName
Trusted_Connection=Yes
DATABASE=Test
WSID=ServerName
APP=Microsoft Data Access Components
SERVER=(local)
Martin Brown
Worked like a champ! I know it's hacky, but that's what I'm dealing with at the moment.
scottm