Jump to content

Help with ODBC


dufran3
 Share

Recommended Posts

I am trying to automagically create a ODBC connection to a SQL Server. Anyone know of any fancy good ways to do this? I know there are some registry entries, but I was hoping maybe there was a way to do it using API or something. Thx for the help!

Link to comment
Share on other sites

I am trying to automagically create a ODBC connection to a SQL Server. Anyone know of any fancy good ways to do this? I know there are some registry entries, but I was hoping maybe there was a way to do it using API or something. Thx for the help!

To answer your question, since no one else has, the best way that I know of to create an ODBC connection is through the registry.

System DSN:

RegWrite("HKCU\Software\ODBC\ODBC.INI\(DSN name)", "Database", "REG_SZ", "(database name)")

RegWrite("HKCU\Software\ODBC\ODBC.INI\(DSN name)", "Driver", "REG_SZ", @SystemDir & "\sqlsrv32.dll")

RegWrite("HKCU\Software\ODBC\ODBC.INI\(DSN name)", "LastUser", "REG_SZ", "(user name)")

RegWrite("HKCU\Software\ODBC\ODBC.INI\(DSN name)", "Server", "REG_SZ", "(server name)")

To list your ODBC connection in the ODBC Administrator:

RegWrite("HKCU\Software\ODBC\ODBC.INI\ODBC Data Sources", "(DSN name)", "REG_SZ", "SQL Server")

Link to comment
Share on other sites

If its a mysql connection that you're trying to make, take a look at: this

if its another ODBC connection that u need, that may also help you out, just take a look at the code and make the proper substitutions.

[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
Link to comment
Share on other sites

I appreciate the help, I tried using that, however it isn't quite what I am looking for. It seems as those just temporarily create a connection, I need to actually add a system DSN on the local computer. I appreciate your help guys!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...