dufran3 Posted October 11, 2006 Share Posted October 11, 2006 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 More sharing options...
AutoChris Posted October 11, 2006 Share Posted October 11, 2006 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 More sharing options...
dufran3 Posted October 11, 2006 Author Share Posted October 11, 2006 Question, the "Last User" key, or the username key, my SQL server also requires a password. Where do I enter that in at? Link to comment Share on other sites More sharing options...
LOULOU Posted October 11, 2006 Share Posted October 11, 2006 Question, the "Last User" key, or the username key, my SQL server also requires a password. Where do I enter that in at?The reply is here http://www.autoitscript.com/forum/index.php?showtopic=20814 Link to comment Share on other sites More sharing options...
ame1011 Posted October 11, 2006 Share Posted October 11, 2006 If its a mysql connection that you're trying to make, take a look at: thisif 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 More sharing options...
dufran3 Posted October 17, 2006 Author Share Posted October 17, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now