hey ! gd evening :)
I'm just facing error while coding on vb.net. I have new customer form. Normaly it has many text boxes , one date time picker and five picture boxes.
this is code snip :

 Dim mstream As New System.IO.MemoryStream()
        customerpic.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
        Dim arrImage() As Byte = mstream.GetBuffer()

        Dim mstream2 As New System.IO.MemoryStream()
        cusidcard.Image.Save(mstream2, System.Drawing.Imaging.ImageFormat.Jpeg)
        Dim arrImage2() As Byte = mstream2.GetBuffer()

        Dim mstream3 As New System.IO.MemoryStream()
        g1idcard.Image.Save(mstream3, System.Drawing.Imaging.ImageFormat.Jpeg)
        Dim arrImage3() As Byte = mstream3.GetBuffer()

        Dim mstream4 As New System.IO.MemoryStream()
        g2idcard.Image.Save(mstream4, System.Drawing.Imaging.ImageFormat.Jpeg)
        Dim arrImage4() As Byte = mstream4.GetBuffer()

        Dim mstream5 As New System.IO.MemoryStream()
        cusregform.Image.Save(mstream5, System.Drawing.Imaging.ImageFormat.Jpeg)
        Dim arrImage5() As Byte = mstream5.GetBuffer()
        query = "INSERT INTO moneycs.customer(Customer_ID, First_Name, Last_Name, NIC_NO, House_NO, Address, City, TP_NO, Membership_Date, Business_Name, G_1ID, G_2ID, C_PIC, C_ID, C_RegApplication)" & _
                "VALUES(@Customer_ID, @First_Name, @Last_Name, @NIC_NO, @House_NO, @Address, @City, @TP_NO, @Membership_Date, @Business_Name, @G_1ID, @G_2ID, @C_PIC, @C_ID, @C_RegApplication)"
        Dim cmd As MySqlCommand = New MySqlCommand(query, con)
        cmd.Parameters.AddWithValue("@Customer_ID", Convert.ToInt32(txtcustormerid.Text))
        cmd.Parameters.AddWithValue("@First_Name", Convert.ToString(txtfirstname.Text))
        cmd.Parameters.AddWithValue("@Last_Name", Convert.ToString(txtlastname.Text))
        cmd.Parameters.AddWithValue("@NIC_NO", Convert.ToString(txtnicno.Text))
        cmd.Parameters.AddWithValue("@House_NO", Convert.ToString(txthouseno.Text))
        cmd.Parameters.AddWithValue("@Address", Convert.ToString(txtaddress.Text))
        cmd.Parameters.AddWithValue("@City", Convert.ToString(txtcity.Text))
        cmd.Parameters.AddWithValue("@TP_NO", Convert.ToString(txtctpno.Text))
        cmd.Parameters.AddWithValue("@Membership_Date", Convert.ToDateTime(dtpmembrshipdate.Value))
        cmd.Parameters.AddWithValue("@Business_Name)", Convert.ToString(txtbusinessname.Text))
        cmd.Parameters.AddWithValue("@G_1ID", arrImage)
        cmd.Parameters.AddWithValue("@G_2ID", arrImage2)
        cmd.Parameters.AddWithValue("@C_PIC", arrImage3)
        cmd.Parameters.AddWithValue("@C_ID", arrImage4)
        cmd.Parameters.AddWithValue("@C_RegApplication", arrImage5)
            MessageBox.Show("Customer Added Sucsessfully !", "Save Customer")
        Catch ex As Exception
        End Try
        If (con.State = ConnectionState.Open) Then
        End If
    End Sub

When I clicked on 'save' button it say 'fatal error encountered while command execution'
But I can't find where I had error. Please help me guys

Re: Can't insert data to mysql db using vb.net 80 80

Your error should be at line no 37.
cmd.Parameters.AddWithValue("@Business_Name)", Convert.ToString(txtbusinessname.Text))
You made an extra charecter in parameter declaration "@Business_Name)"

Re: Can't insert data to mysql db using vb.net 80 80

yes you are right sir :)

Even I double checked I can't find that error :)

Re: Can't insert data to mysql db using vb.net 80 80

If your probs. solved please mark your post as solved.

Be a part of the DaniWeb community

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