Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

You mean DSNless? of course can

 

sConnectionString = "Driver={mySQL};Server=SERVERNAME;Port=3306;Option=131072;Database=MYDB;Uid=USERNAME;Pwd=PASSWORD"

[/Quote]

Posted

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

Posted

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"

Posted

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

Some people are wise and some are other-wise.
Posted (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 by sizer
Some people are wise and some are other-wise.
Posted

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'


Some people are wise and some are other-wise.
Posted

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.

Posted

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

Some people are wise and some are other-wise.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...