0

Please help me. I am trying to insert into mysql database, but it is throwing this error. Fatal error encounter during command execution.
this is the sample of code am trying to run

 cn.Open()
 cmd.Connection = cn
cmd.CommandText = "insert into corps(callup,statecode,surname,firstname,othername) values(?,?,?,?,?)
 With cmd.Parameters
     .Add("@callup", OleDbType.VarChar).Value = txtcallupno.Text
     .Add("@statecode", OleDbType.VarChar).Value = txtstatecode.Text
     .Add("@surname", OleDbType.VarChar).Value = txtsurname.Text
     .Add("@first", OleDbType.VarChar).Value = txtfirstname.Text
     .Add("@othername", OleDbType.VarChar).Value = txtothername.Text
 End With
     cmd.ExecuteNonQuery()
    cmd.Parameters.Clear()
    cn.Close()

if am using access database, this code run very smooth and fine, but when i change my database to mysql, i am having this error.please help me, if i need to add anything else. Thanks

3
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by mahardikawkwk
0

According to me ur Datatype is not correct....

try using

.Add("@callup", SqlDbType.VarChar)
.Add("@statecode", SqlDbType.VarChar) 

use SqlDbType instead of OleDbType

Edited by poojavb

0

•̸ŤђαϞĸs for ur reply..I have changed it to SqlDbType, but it still giving the same error.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.