MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 31st, 2003, 02:38 PM
snowman snowman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Sweden
Posts: 2 snowman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old February 1st, 2003, 03:12 PM
davmorr davmorr is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 2 davmorr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #3  
Old February 1st, 2003, 06:04 PM
snowman snowman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Sweden
Posts: 2 snowman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old February 2nd, 2003, 02:37 PM
davmorr davmorr is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 2 davmorr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > C# problem with mySQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT