0

I am using Vb.net 2010 and MySQL. Insert is working but got problem in update.

con.Open()

Dim cmd As New Odbc.odbcCommand("update date1 set event_title='" + txteventtitle.Text + "',description='" + rchdescription.Text + "',calender='" + DateTimePicker1.Value.Date() + "')", con)

cmd.ExecuteNonQuery()

con.Close()

This query doesn't update my record into table. As i m beginner i need step by step procedure to update a query. I am not using any datagrid to display my records.

Please help me. Thank you.

Tony Stark
  • 8,064
  • 8
  • 44
  • 63
  • What is the error? Also are you sure that "',calender='" is right?Maybe is calendar? – Nianios Apr 09 '13 at 07:18
  • 3
    Also you close the brackets ) but you haven't opened them – Nianios Apr 09 '13 at 07:18
  • Why do you use ODBC instead of a more complete ADO.NET provider like the [MySql Connector](http://www.mysql.com/products/connector/)? – Steve Apr 09 '13 at 07:22
  • Two important notes: you should switch [Option Strict On](http://www.codinghorror.com/blog/2005/08/option-strict-and-option-explicit-in-vbnet-2005.html) and you should look into [parameterised queries](http://stackoverflow.com/questions/542510/how-do-i-create-a-parameterized-sql-query-why-should-i) as your code is vulnerable to sql injection – Matt Wilko Apr 09 '13 at 08:02

1 Answers1

0

Remove the closing paren + "')" in the query.

nl-x
  • 11,762
  • 7
  • 33
  • 61