c# connect to mysql databae

How many method that c# connect to my sql  odbc , .net and what is the difference
teeraAsked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
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.
0
 
käµfm³d 👽Commented:
>>  The difference between the two

The difference between the THREE   :)
0
 
GlobaLevelProgrammerCommented:
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...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.