473,516 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MySQL OleDbConnection

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
5 13543
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
"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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
17520
by: shridhar_km | last post by:
Hi all, I am using OleDbConnection for connecting with MySQL.Using INSERT query for inserting images to MySQL db with C# code. The code is given below : string strConn="PROVIDER=MySQLProv;SERVER=192.168.1.8;DB=test;UID=test;PWD=;PORT=;"; OleDbConnection objConn; objConn=new OleDbConnection (strConn); objConn.Open(); Image...
2
2191
by: KaHuNa | last post by:
this code works perfectly when i use it on the server where mySQL is installed, but i have a security error when i use it on a client computer. I don't know how i can change that. using System; using System.Data.Odbc; class database {
1
1981
by: The Bear | last post by:
Has anyone successfully used MySQL with C#? I'm having problems using the Update command Here is the code snippet. I am able to connect to the database. However when I try to update the database with the changes in the dataset I get the following error: An unhandled exception of type 'System.InvalidOperationException' occurred in...
5
1523
by: Paul | last post by:
Hi I did the following in an effort to connect to mysql using VB.net on a windows XP pro machine. I made reference to and used the import statement as follows : Imports Microsoft.Data.Odbc I then created my connection with the following :
6
1948
by: Martin Ho | last post by:
What would be the easiest way to connect to Mysql from VB.NET? thanks ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
1
1852
by: Lorenzo | last post by:
I have a problem with oledb connection string of Mysql for .NET I installed MyOleDB3.exe Mysql server version 4.1.8-nt I used this connection string : strConnectionString="Provider=MySqlProv;Persist Security Info=True;Location=10.0.0.17;Data Source="+strDatabase+";User Id="+strUser+";Password="+strPassword+";"; I used OleDbConnection...
3
5971
by: h4xPace | last post by:
I am building a MySQL query application, and I have run into a small snag. MySQL has released a set of classes that extend the .NET framework base data classes (command, connection, etc), and I am using them to interact with the MySQL server (on localhost). Everything works great on that side of the aisle. However, I have never worked with...
6
4464
by: vj83 | last post by:
Hi, I have a C#.net application in which i have read the datas from excel sheet and displayed in a datagrid in my Aspx form. The code is here private void Button2_Click(object sender, System.EventArgs e) { try
16
7178
by: SyGC | last post by:
Hello, Im trying to connect to a MySQL DB on my home network (testing purposes) using the following VB.NET code; Imports System.Data.OleDb Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim SQLConnection As OleDbConnection
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.