By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,631 Members | 892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,631 IT Pros & Developers. It's quick & easy.

MySQL OleDbConnection

P: n/a
Hello.

I am trying to get a connection to MySQL using OleDb but it seems that I am
making something wrong.
I´ve found this source in the net but it doesn´t work for me:

System.Data.OleDb.OleDbConnection con;
con=new System.Data.OleDb.OleDbConnection("");
con.ConnectionString="Provider=Microsoft.Jet.OLEDB .4.0;Data Source=test;";
con.Open();

Where can I set the path to my localhost where mySql is running?
Trying to put it in Data Source I get an exception - invalid filename
Is the provider ok? Don´t I need a username and password?

And how does the connection string look when I want to create my FIRST
database?
Can I then leave the Data Source empty?

Having less experience working with databases I am also thankful for any
good resource tips on the net.
Thanks to anyone who can help me out!

Desperate greetings,
Tim.

Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
This article should help
http://dev.mysql.com/tech-resources/articles/dotnet/

You need to install a driver that will provide MySQL data to the OLEDB
interface, which is used by .NET. I believe that there are drivers
available, and that the article above will point you to them.

The connection string you gave allows you to connect to a JET database
(read: Microsoft Access). It won't work for MySQL (as you've discovered).

Good luck,
--- Nick

"Tim Bücker" <ti*************@web.de> wrote in message
news:ca**********@news.uni-koblenz.de...
Hello.

I am trying to get a connection to MySQL using OleDb but it seems that I am making something wrong.
I´ve found this source in the net but it doesn´t work for me:

System.Data.OleDb.OleDbConnection con;
con=new System.Data.OleDb.OleDbConnection("");
con.ConnectionString="Provider=Microsoft.Jet.OLEDB .4.0;Data Source=test;";
con.Open();

Where can I set the path to my localhost where mySql is running?
Trying to put it in Data Source I get an exception - invalid filename
Is the provider ok? Don´t I need a username and password?

And how does the connection string look when I want to create my FIRST
database?
Can I then leave the Data Source empty?

Having less experience working with databases I am also thankful for any
good resource tips on the net.
Thanks to anyone who can help me out!

Desperate greetings,
Tim.

Nov 16 '05 #2

P: n/a
"Nick Malik" <ni*******@hotmail.nospam.com>
This article should help
http://dev.mysql.com/tech-resources/articles/dotnet/
Thanks for answering! I´ve read this article but I hope that it is an older
one reading this line here:
"MySQL currently doesn't officially support MyOLEDB, so this solution will
not be discussed here."

If it is not an older one - is it correct that the only "official" way to
connect to mysql using C# is odbc right now?
(Not regarding ByteFX.Data & CoreLabs)
The connection string you gave allows you to connect to a JET database
(read: Microsoft Access). It won't work for MySQL (as you've discovered).
Ah, thanks. JET = Access; didn´t know that. Damn Copy & Paste, ... ;-)
Greetings,
Tim.
"Tim Bücker" <ti*************@web.de> wrote

I am trying to get a connection to MySQL using OleDb but it seems that I

am
making something wrong.
I´ve found this source in the net but it doesn´t work for me:

System.Data.OleDb.OleDbConnection con;
con=new System.Data.OleDb.OleDbConnection("");
con.ConnectionString="Provider=Microsoft.Jet.OLEDB .4.0;Data Source=test;"; con.Open();

Where can I set the path to my localhost where mySql is running?
Trying to put it in Data Source I get an exception - invalid filename
Is the provider ok? Don´t I need a username and password?

And how does the connection string look when I want to create my FIRST
database?
Can I then leave the Data Source empty?

Having less experience working with databases I am also thankful for any
good resource tips on the net.

Nov 16 '05 #3

P: n/a
not sure what it means to say that there's an Official way to use MySQL!

However, what's wrong with using ODBC for your provider, instead of OLEDB?
ODBC is a good solid interface. All the bad press came from really poorly
implemented drivers.

You can use an ODBC driver from .NET and there's an open source one
available (as listed in the article).

I do hope I'm being helpful.

--- Nick

"Tim Bücker" <ti*************@web.de> wrote in message
news:ca**********@news.uni-koblenz.de...
"Nick Malik" <ni*******@hotmail.nospam.com>
This article should help
http://dev.mysql.com/tech-resources/articles/dotnet/
Thanks for answering! I´ve read this article but I hope that it is an

older one reading this line here:
"MySQL currently doesn't officially support MyOLEDB, so this solution will
not be discussed here."

If it is not an older one - is it correct that the only "official" way to
connect to mysql using C# is odbc right now?
(Not regarding ByteFX.Data & CoreLabs)
The connection string you gave allows you to connect to a JET database
(read: Microsoft Access). It won't work for MySQL (as you've discovered).

Ah, thanks. JET = Access; didn´t know that. Damn Copy & Paste, ... ;-)
Greetings,
Tim.
"Tim Bücker" <ti*************@web.de> wrote

I am trying to get a connection to MySQL using OleDb but it seems that I
am
making something wrong.
I´ve found this source in the net but it doesn´t work for me:

System.Data.OleDb.OleDbConnection con;
con=new System.Data.OleDb.OleDbConnection("");
con.ConnectionString="Provider=Microsoft.Jet.OLEDB .4.0;Data

Source=test;"; con.Open();

Where can I set the path to my localhost where mySql is running?
Trying to put it in Data Source I get an exception - invalid filename
Is the provider ok? Don´t I need a username and password?

And how does the connection string look when I want to create my FIRST
database?
Can I then leave the Data Source empty?

Having less experience working with databases I am also thankful for

any good resource tips on the net.


Nov 16 '05 #4

P: n/a
On Sat, 12 Jun 2004 18:39:19 +0200, Tim Bücker wrote:
Hello.

I am trying to get a connection to MySQL using OleDb but it seems that I am
making something wrong.
I´ve found this source in the net but it doesn´t work for me:

System.Data.OleDb.OleDbConnection con;
con=new System.Data.OleDb.OleDbConnection("");
con.ConnectionString="Provider=Microsoft.Jet.OLEDB .4.0;Data Source=test;";
con.Open();

Where can I set the path to my localhost where mySql is running?
Trying to put it in Data Source I get an exception - invalid filename
Is the provider ok? Don´t I need a username and password?

And how does the connection string look when I want to create my FIRST
database?
Can I then leave the Data Source empty?

Having less experience working with databases I am also thankful for any
good resource tips on the net.
Thanks to anyone who can help me out!

Desperate greetings,
Tim.


Tim,

I was wondering - have you considered using the ByteFx MySQL data provider?
It has been adopted by the MySQL team as the official MySQL data provider
for .NET. I have used it (and am using it :) and so far it seems quite
robust and fast. The nice thing is that it was written entirely in C# -
and requires none of the MySQL client libraries to be installed. You can
download it at:

http://www.bytefx.com

Another advantage - it works equally well under Mono as it does under .NET
- in fact it ships as part of the Mono distribution.

--
Tom Shelton [MVP]
Nov 16 '05 #5

P: n/a
"Tim Bücker" <ti*************@web.de> wrote:
I am trying to get a connection to MySQL using OleDb but it seems that I am making something wrong.


A big thanks to both of you, Nick Malik and Tom Shelton. You´re help did
help me.
I think I will then use ODBC as provider because ByteFx is only a beta
version but perhaps I will try that provider later.
A switch between different providers should be possible too. Shouldn´t be
complicated for ByteFx as it implements all standard ADO.NET provider
interfaces...

Greetings,
Tim.
Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.