problems insert data in database using table adapter
-
When I do a database insert there are no errors displayed, but when I check the database the data does not insert into the database. Why? Here is my code. I declared addRow globally.
addRow = lpDataSet.Tables("tbl_students").NewRow() addRow("stud_cell") = txtStudCell.Text addRow("stud_phone") = txtStudPhone.Text lpDataSet.Tables("tbl_students").Rows.Add(addRow) Try studTableAdapter.Update(addRow) Catch err As Exception MessageBox.Show(err.Message) End Try
-
When I do a database insert there are no errors displayed, but when I check the database the data does not insert into the database. Why? Here is my code. I declared addRow globally.
addRow = lpDataSet.Tables("tbl_students").NewRow() addRow("stud_cell") = txtStudCell.Text addRow("stud_phone") = txtStudPhone.Text lpDataSet.Tables("tbl_students").Rows.Add(addRow) Try studTableAdapter.Update(addRow) Catch err As Exception MessageBox.Show(err.Message) End Try
Try this code
addRow = lpDataSet.Tables("tbl_students").NewRow() addRow("stud_cell") = txtStudCell.Text addRow("stud_phone") = txtStudPhone.Text lpDataSet.Tables("tbl_students").Rows.Add(addRow) Try studTableAdapter.Update() Catch err As Exception MessageBox.Show(err.Message) End Try
:-\ -
Try this code
addRow = lpDataSet.Tables("tbl_students").NewRow() addRow("stud_cell") = txtStudCell.Text addRow("stud_phone") = txtStudPhone.Text lpDataSet.Tables("tbl_students").Rows.Add(addRow) Try studTableAdapter.Update() Catch err As Exception MessageBox.Show(err.Message) End Try
:-\When I take the dataRow variable out of the table adapter update function I get the blue line. The error says the following.
Overload resolution failed because no accesdsible update accepts this number of arguments.
Why wont the update update or add a row to the database with or without the dataRow variable as an argument?
-
When I take the dataRow variable out of the table adapter update function I get the blue line. The error says the following.
Overload resolution failed because no accesdsible update accepts this number of arguments.
Why wont the update update or add a row to the database with or without the dataRow variable as an argument?
Oops :doh: Sorry addRow = lpDataSet.Tables("tbl_students").NewRow() addRow("stud_cell") = txtStudCell.Text addRow("stud_phone") = txtStudPhone.Text lpDataSet.Tables("tbl_students").Rows.Add(addRow) Try studTableAdapter.Update(lpDataSet, "tbl_students" ) Catch err As Exception MessageBox.Show(err.Message) End Try
-
Oops :doh: Sorry addRow = lpDataSet.Tables("tbl_students").NewRow() addRow("stud_cell") = txtStudCell.Text addRow("stud_phone") = txtStudPhone.Text lpDataSet.Tables("tbl_students").Rows.Add(addRow) Try studTableAdapter.Update(lpDataSet, "tbl_students" ) Catch err As Exception MessageBox.Show(err.Message) End Try
You can't put the name of a dataset coma the name of a table.
-
When I do a database insert there are no errors displayed, but when I check the database the data does not insert into the database. Why? Here is my code. I declared addRow globally.
addRow = lpDataSet.Tables("tbl_students").NewRow() addRow("stud_cell") = txtStudCell.Text addRow("stud_phone") = txtStudPhone.Text lpDataSet.Tables("tbl_students").Rows.Add(addRow) Try studTableAdapter.Update(addRow) Catch err As Exception MessageBox.Show(err.Message) End Try