I answered the exact same question earlier here:
Vb.net 4 textbox 1 datagridview 1 save button how inert value in sqldatabase[
^] .
Based on the post you have not tried the suggested actions. So have a try with something like the following. I don't have a compiler at hand so sorry for any typos
con.Open()
com.CommandText = "insert into three(sid,supid,supname,supperson) values(@sid,@supid,@supname,@supperson)"
com.Parameters.AddWithValue("@sid", TextBox1.Text)
com.Parameters.AddWithValue("@supid", TextBox2.Text)
com.Parameters.AddWithValue("@supname", TextBox3.Text)
com.Parameters.AddWithValue("@supperson", TextBox4.Text)
com.ExecuteNonQuery()
com.CommandText = "insert into three (pno,pname,qty,price) values (@pno,@pname,@qty,@price)"
com.Parameters.Add("@pno", SqlDbType.VarChar, 100)
com.Parameters.Add("@pname", SqlDbType.VarChar, 100)
com.Parameters.Add("@qty", SqlDbType.VarChar, 100)
com.Parameters.Add("@price", SqlDbType.VarChar, 100)
For i As Integer = 0 To DataGridView1.Rows.Count - 1
com.Parameters("@pno").Value = DataGridView1.Rows(i).Cells(0).Value
com.Parameters("@pname".Value = DataGridView1.Rows(i).Cells(1).Value
com.Parameters("@qty".Value = DataGridView1.Rows(i).Cells(2).Value
com.Parameters("@price".Value = DataGridView1.Rows(i).Cells(3).Value
com.ExecuteNonQuery()
Next
connection.Close(
All the questions in the previous answer still apply and check the data type and lengths prior using this code. For example I do not know if the type of PNO is varchar or something else.