MrTV
asked on
c# connect to mysql databae
How many method that c# connect to my sql odbc , .net and what is the difference
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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_I D", SqlDbType.Int)).Value = var_xxIxT_ID
dataReader = command.ExecuteReader(Syst em.Data.Co mmandBehav ior.CloseC onnection)
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...
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
dataReader = command.ExecuteReader(Syst
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...
The difference between the THREE :)