iam trying to save records in a form to my mysql database. but i keep geting an error on the
cmd.ExecuteNonQuery line.

Please post both the code and the error message; we can't help you if we don't know what's going on.

`Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    Dim con As New MySqlConnection
    Dim cmd As New MySqlCommand
    Try
        con.ConnectionString = "Server=localhost;Database=rubber;Uid=root;Pwd=;"
        cmd.Connection = con
        con.Open()
        cmd.CommandText = "INSERT INTO customerdetails (ID,First Name,Second Name,Date,Quantity,Type) VALUES (@ID, @FirstName, @SecondName, @Date, @Quantity, @Type)"
        cmd.Parameters.AddWithValue("@ID", TextBox1.Text)
        cmd.Parameters.AddWithValue("@First Name", TextBox2.Text)
        cmd.Parameters.AddWithValue("@Second Name", TextBox3.Text)
        cmd.Parameters.AddWithValue("@Date", TextBox4.Text)
        cmd.Parameters.AddWithValue("@Quantity", TextBox5.Text)
        cmd.Parameters.AddWithValue("@Type", DropDownList1.Text)
        cmd.ExecuteNonQuery()
    Finally
        con.Close()
    End Try
End Sub`

the error is then like this,
An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll but was not handled in user code

Additional information: Fatal error encountered during command execution.

the it tells me that parameter @firstname should be declared

Are you using the standard MySQL Connector/NET? That's what it looks like; I'm just making sure.

An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll but was not handled in user code

That means something's wrong with your query--can you put a Catch block in your code that prints out the exception details?

Aha. I might have found your problem.

cmd.CommandText = "INSERT INTO customerdetails (ID,First Name,Second Name,Date,Quantity,Type) VALUES (@ID, @FirstName, @SecondName, @Date, @Quantity, @Type)"

The MySQL Connector/NET doesn't support '@' as a parameter indicator any more. You'll want to use '?' instead.

yeah, thanks alot. it has worked.

i have another problem please help me. the post is Asp.net and mysql. i posted it.

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.