|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
C# problem with mySQL
Hello
I have done this Turtorial URL its about to connect a Access file to the C# language using OleDb. I have some problem to connect it to mysql server. I have instlld the mysql server and got it to run, now i have to change this Myconnection = new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source=C:\familyTree.mdb"); Myconnection.Open(); to get it handel mysql server instead, how do i do this? i cant find any info about it. My computer name is JIMMY-217 but i supose that you could use locahost to, i have not done any changes to the mysql so probley i could loogin to root with no password. How do i have to change the OLEDBConnector to get it connect to mysql server? Best regards Jimmy |
|
#2
|
|||
|
|||
|
Re: C# problem with mySQL
There's not much documentation on the web ... especially MSDN - I wonder why
, but the following should help you get started. First, go get the MySQL Connector/ODBC (also known as MyODBC) from mysql.com: URL After installing it, set up a DSN to your mysql database through your Data Source(ODBC) wizard. Rather than going through the process here, Sushant Bhatia put together a nice tutorial at the following URL: URL Hope this helps! |
|
#3
|
|||
|
|||
|
Thanks
Hello again, now i have get the code to work, it shows the stuf in the mysql server in to a form in C#. <code>{ IDataReader reader; IDbCommand cmd; System.Data.OleDb.OleDbConnection con; con=new System.Data.OleDb.OleDbConnection(""); con.ConnectionString="server=localhost;Provider=MySQLProv;Data Source=database;"; try { con.Open(); if (con.State==ConnectionState.Open) { cmd = con.CreateCommand(); cmd.CommandText = "UPDATE humans SET Name = 'Nisse' WHERE id = '3'"; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT * FROM humans"; reader = cmd.ExecuteReader(); while (reader.Read()) { lb.Items.Add(reader.GetString(1) + " " + reader.GetString(2)); } MessageBox.Show("Connection to MySQL opened through OLE DB Provider"); con.Close(); } } catch(Exception ex) { MessageBox.Show(ex.Message); } } }</code> But as you se i am trying to update the mysql data base. This does not work i get the following error DB_ERRORSINCOMMAND(0x80040E14) Do you got a ide of why i get this error? Last edited by snowman : February 1st, 2003 at 08:45 PM. |
|
#4
|
|||
|
|||
|
Re: C# problem with mySQL
Sorry, I haven't messed with writing to a MySQL db from C#, yet. If I get back around to playing with that combo any time soon, I'll post it here. If you figure out the error, please post the solution, I'd like to see it.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > C# problem with mySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|