I'm using mysql as database . I use odbc connector to use the database , it's working fine with select statements ,but when I use insert statement with parameter it is not working. may I know if the command parameter property works with mysql or it only works with mssql.

It's not working.
Error :
ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.1.37]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'name1)' at line 1

my code is like this:
Dim con As New OdbcConnection("dsn=shop1_con;uid=root;pwd=123")
Try
If Trim(TextBox1.Text) = "" Then
Throw New Exception("Please Enter the name first!")
Else
Dim cmd As New OdbcCommand("insert into table2(name) values (?name1)", con)
'cmd.Parameters.Add("?name1", SqlDbType.NVarChar)
'cmd.Parameters(0).Value = TextBox1.Text
cmd.Parameters.AddWithValue("?name", TextBox1.Text)
If con.State = ConnectionState.Closed Then
con.Open()
End If
cmd.ExecuteNonQuery()
If con.State = ConnectionState.Open Then
con.Close()
End If
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
TextBox1.Focus()
End Try

I had read somewhere that either MySQl or ODBC does not accept named parameter.

Let update query be:

Dim cmd As New OdbcCommand("insert into table2(name) values (?)", con)
cmd.Parameters.AddWithValue("?", TextBox1.Text)

'PS: I also try it with putting only ? in the insert sql and put a name in the AddWithValue and it works
Dim cmd As New OdbcCommand("insert into table2(name) values (?)", con)
cmd.Parameters.AddWithValue("?Name", TextBox1.Text)

hth

This article has been dead for over six months. Start a new discussion instead.