Asso79 Posted June 13, 2003 Posted June 13, 2003 DSN mysql Can i create a dsn mysql writing code without to in administrator tools? Quote
bungpeng Posted June 13, 2003 Posted June 13, 2003 You mean DSNless? of course can sConnectionString = "Driver={mySQL};Server=SERVERNAME;Port=3306;Option=131072;Database=MYDB;Uid=USERNAME;Pwd=PASSWORD" [/Quote] Quote
Asso79 Posted June 14, 2003 Author Posted June 14, 2003 Its ok. But i cant create a new dsn for odbc with code vbnet without to go in administrator tools and odbc (new dsn). This is connection string: sConnectionString = " Driver={mySQL};Server=SERVERNAME;Port=3306;Option=131072;Database=MYDB ;Uid=USERNAME;Pwd=PASSWORD but i cant create a new dsn Thanks Quote
bungpeng Posted June 14, 2003 Posted June 14, 2003 You can't create with this connection string? you need to change some values of it like "SERVERNAME", "MYDB", "USERNAME", "PASSWORD" regarding your database setting. And, sorry, there is no space in front of "Driver" Quote
sizer Posted June 14, 2003 Posted June 14, 2003 you could create new dsn over some Registry entery !! HKEY_LOCAL_MACHINE --> Software --> ODBC --> ODBC.INI !! If you are intested for this solution let me know!! :D Quote Some people are wise and some are other-wise.
sizer Posted June 16, 2003 Posted June 16, 2003 (edited) Imports System Imports System.Environment ... ... ... Dim key, key1 As RegistryKey Dim subkey, subkey1 As RegistryKey key = Registry.LocalMachine subkey = key.CreateSubKey("SOFTWARE\ODBC\ODBC.INI\NEWDSN") 'Line AB subkey.SetValue("database", "wbamar") '' your dbname subkey.SetValue("description", "") ''default subkey.SetValue("driver", SystemDirectory.ToString & "\" & "myodbc.dll") ''driver for mySQL subkey.SetValue("option", "0") '' default 0 subkey.SetValue("password", "") ''your pass subkey.SetValue("port", "3306") ''default is 3306 subkey.SetValue("server", "MYCOMP") '' name of server/computer or localhost subkey.SetValue("stmt", "") ''default subkey.SetValue("user", "root") ''your uname key.Close() subkey.Close() key1 = Registry.LocalMachine subkey1 = key.OpenSubKey("SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", True) subkey1.SetValue("NEWDSN", "MySQL") ''first value must me ''same as name in line 'Line AB' key1.Close() subkey1.Close() :D Edited June 16, 2003 by sizer Quote Some people are wise and some are other-wise.
Asso79 Posted June 16, 2003 Author Posted June 16, 2003 It's ok it's need to: Imports Microsoft.Win32 Quote
sizer Posted June 16, 2003 Posted June 16, 2003 because you dont have--> ... Imports System.Win32 ... Quote Some people are wise and some are other-wise.
Asso79 Posted June 16, 2003 Author Posted June 16, 2003 i execute the code but not add a new dsn. Quote
Asso79 Posted June 16, 2003 Author Posted June 16, 2003 Perhaps because i use mysql and mysql odbc driver 3.51 Quote
sizer Posted June 16, 2003 Posted June 16, 2003 yes, key1 = Registry.LocalMachine subkey1 = key.OpenSubKey("SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", True) subkey1.SetValue("NEWDSN", "MySQL ODBC 3.51 Driver") ''first value must me ''same As Name In Line 'Line AB' Quote Some people are wise and some are other-wise.
Asso79 Posted June 16, 2003 Author Posted June 16, 2003 Excuse me i have the file odbc.ini in directory windows so i write: subkey = key.CreateSubKey("windows\ODBC.INI\NEWDSN") but the error is An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll Additional information: The parameter is incorrect. Quote
*Experts* mutant Posted June 16, 2003 *Experts* Posted June 16, 2003 Slashes are not valid for any folder, file or registry key names and things like that. Quote
sizer Posted June 16, 2003 Posted June 16, 2003 with code that i post, your are modifing windows registry not file so type exacty as i post except nname.pass,database...blah.. go to start --> Run -->type -->Regedit and then check keys HKEY_LOCAL_MACHINE --> SOFTWARE --> ODBC --> ODBC.INI Quote Some people are wise and some are other-wise.
Asso79 Posted June 16, 2003 Author Posted June 16, 2003 Thank you, i see that u write but not add a new dsn. I change: subkey.SetValue("server", "localhost") Quote
Asso79 Posted June 16, 2003 Author Posted June 16, 2003 It's ok add a newdsn in registry but is not add in administrative tools and odbc? True? Quote
Asso79 Posted June 16, 2003 Author Posted June 16, 2003 It's all correct thank you very much :) Quote
sizer Posted June 16, 2003 Posted June 16, 2003 no problem :D Quote Some people are wise and some are other-wise.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.