mihaiguran Posted May 3, 2004 Posted May 3, 2004 I've found the folowing example conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 DRIVER};" _ & "SERVER=localhost;" _ & "UID=root;PWD=;OPTION=3" conn.Open() When I try to open the database, This error message apears: An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Info.exe Additional information: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified I have on my computer MySql 3.23. So I tryed to replace '3.51' with '3.23' but I get the same error. What shell I do? :confused: Quote
michael_hk Posted May 4, 2004 Posted May 4, 2004 Take a look at this Quote There is no spoon. <<The Matrix>>
keitsi Posted May 4, 2004 Posted May 4, 2004 ByteFX (with LGPL license) or MySQLDriverCS (with GPL license) pwns ODBC with the MyODBC-client. ;) You don't even need to have MyODBC installed. Also, using MyODBC in commercial environment is illegal (says MySQL Ab). I found it much better way to use the ByteFX client. Maybe you could try MySQLdriverCS if your app is open source, I've seen few people say that MySQLdriverCS is better. I'm using ByteFX and works fine for me. Plus, it's LGPL and I for sure can use it legally in commercial apps. http://www.bytefx.com/ http://sourceforge.net/projects/mysqldrivercs/ Quote BS - Beer Specialist
mihaiguran Posted May 4, 2004 Author Posted May 4, 2004 (edited) Thank you very much! :) I managed to read teh data from the tables, but I couldn't update the records. I have tryed like this: 'ds is the dataset with the changed values. Dim objDA2 As New OdbcDataAdapter Dim StrSQL2 As String = "SELECT * FROM Clienti" objDA2 = New Microsoft.Data.Odbc.OdbcDataAdapter(StrSQL2, objConn1) objDA2.UpdateCommand = New Microsoft.Data.Odbc.OdbcCommand objDA2.UpdateCommand.Connection = objConn1 objDA2.UpdateCommand.CommandText = "UPDATE Clienti SET ID=@ID, Denumire = @Denumire WHERE (ID = @Original_ID) AND (Denumire = @Original_Denumire OR @Original_Denumire IS NULL AND Denumire IS NULL) ; SELECT ID, Denumire FROM Clienti WHERE (ID = @ID)" objDA2.UpdateCommand.Parameters.Add(New Microsoft.Data.Odbc.OdbcParameter("@ID", Microsoft.Data.Odbc.OdbcType.BigInt, 8, "ID")) objDA2.UpdateCommand.Parameters.Add(New Microsoft.Data.Odbc.OdbcParameter("@Denumire", Microsoft.Data.Odbc.OdbcType.Text, 50, "Denumire")) objDA2.UpdateCommand.Parameters.Add(New Microsoft.Data.Odbc.OdbcParameter("@Original_ID", Microsoft.Data.Odbc.OdbcType.BigInt, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing)) objDA2.UpdateCommand.Parameters.Add(New Microsoft.Data.Odbc.OdbcParameter("@Original_Denumire", Microsoft.Data.Odbc.OdbcType.Text, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Denumirea", System.Data.DataRowVersion.Original, Nothing)) objDA2.Update(ds, "clienti") The table doesn't change at all. What did I do rong? Edited May 5, 2004 by mihaiguran Quote
mihaiguran Posted May 5, 2004 Author Posted May 5, 2004 I found one mistake. acceptchange was true. I changed the code like this Dim StrSQL2 As String = "SELECT * FROM Clienti" Dim objDA2 = New Microsoft.Data.Odbc.OdbcDataAdapter(StrSQL2, objConn1) objDA2.UpdateCommand = New Microsoft.Data.Odbc.OdbcCommand objDA2.UpdateCommand.Connection = objConn1 objDA2.UpdateCommand.CommandText = "UPDATE Clienti SET ID=@ID, Denumire = @Denumire, WHERE (ID = @Original_ID) AND (Denumire = @Original_Denumire OR @Original_Denumire IS NULL AND Denumire IS NULL)" objDA2.UpdateCommand.Parameters.Add(New Microsoft.Data.Odbc.OdbcParameter("@ID", Microsoft.Data.Odbc.OdbcType.BigInt, 8, "ID")) objDA2.UpdateCommand.Parameters.Add(New Microsoft.Data.Odbc.OdbcParameter("@Denumire", Microsoft.Data.Odbc.OdbcType.Text, 50, "Denumire")) objDA2.UpdateCommand.Parameters.Add(New Microsoft.Data.Odbc.OdbcParameter("@Original_ID", Microsoft.Data.Odbc.OdbcType.BigInt, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing)) objDA2.UpdateCommand.Parameters.Add(New Microsoft.Data.Odbc.OdbcParameter("@Original_Denumire", Microsoft.Data.Odbc.OdbcType.Text, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Denumirea", System.Data.DataRowVersion.Original, Nothing)) objDA2.Update(ds, "clienti") I get the error message:"Concurrency violation: the UpdateCommand affected 0 records." Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.