I have just ported my database connection over to MySQL using ODBC. However, none of my parameters are being substituted out into the query and are appearing in my database as null.
I am adding parameters to my query as shown below:
OdbcCommand myCommand = myConnection.getCommand("INSERT INTO entries(text, name, screen_name, user_id, posi_score)values(@txt, @nm, @scrNm, @uid, @posi_score)"); myCommand.Parameters.AddWithValue("@txt", txt); myCommand.Parameters.AddWithValue("@nm", nm); myCommand.Parameters.AddWithValue("@scrNm", scrNm); myCommand.Parameters.AddWithValue("@uid", uid); myCommand.Parameters.AddWithValue("@posi_score", posiScore); myConnection.openConnection(); try { myCommand.ExecuteNonQuery(); } catch (Exception e) { Console.Write("Insert failed on entries "+e.Message); }
|
Is there a different method for adding command parameters for ODBC connections?
Kirtan PatelPosted Nov 5, 2009, 6:21 AM
After installing my SQL Connector You will have New Name space
System.Data.MySql
then you can use all the Facilities better and you will easily handle this type of operation :)
Download My SQL Connector from Here
http://dev.mysql.com/downloads/connector/net/6.2.html
if my answer helped you then check "Do you like this answer" check Box :)
Ben GannawayPosted Nov 5, 2009, 7:39 AM