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

Recommended Answers

All 4 Replies

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

try using

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

use SqlDbType instead of OleDbType

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.