Go Premium for a chance to win a PS4. Enter to Win


c# connect to mysql databae

Posted on 2010-11-15
Medium Priority
Last Modified: 2012-06-21
How many method that c# connect to my sql  odbc , .net and what is the difference
Question by:teera
  • 2
LVL 75

Accepted Solution

käµfm³d   👽 earned 2000 total points
ID: 34135961
I believe this is what you are asking:

To connect to MySql, you can use either ODBC, OLEDB, or the .NET connector. The difference between the two is how they connect and interact with the database.

ODBC is the oldest of the technologies. If I recall correctly, it is the most generic of the the three and was designed to be able to connect to the various DBs of the time. Because of its genericness, it is the least efficient.

I don't know much about OLEDB except that it is a successor to ODBC and I believe it slightly outperforms ODBC.

The .NET connector for a DB is usually coded by the maintainer of the DB itself, and therefore is typically the best performing of the three.
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34135962
>>  The difference between the two

The difference between the THREE   :)
LVL 10

Expert Comment

ID: 34155436
ADO.NET is the best and allows you to create mulitple join statements, whereas ODBC, and OLEDB you can only hit one table at a time...

Plus with ADO.NET you have use of parameters which prevents SQL injection and the dataaptor lets you easily find data that you just quried....its really a step up...

example of parameters to prevent sql injection

Dim SQLstring As String = "SELECT * FROM PRODUCT p Join customer c ON  c.id = p.id WHERE WxxD = @var_xxIxt_ID AND 1 = 1"

 Using command As New SqlCommand(SQLstring, sqlConn)
    command.Parameters.Add(New SqlParameter("@var_xxIxt_ID", SqlDbType.Int)).Value = var_xxIxT_ID
    dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
    If dataReader.HasRows Then
        Do While dataReader.Read()

with the old stuff I would add " AND 1 = 1 " as a trick to prevent sql injection...

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Screencast - Getting to Know the Pipeline
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question