Problem with datatype in database insert
-
I have 2 phone number fields in the database that right now are a text dataType. They were an int, then I changed them to varchar(13). When I try to do an insert into the database there is an exception that says the following.
Failed to convert paramater value from a string to an Integer.
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
-
I have 2 phone number fields in the database that right now are a text dataType. They were an int, then I changed them to varchar(13). When I try to do an insert into the database there is an exception that says the following.
Failed to convert paramater value from a string to an Integer.
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
AAGTHosting wrote:
Try studTableAdapter.Update(addRow)
Me thinks you didn't update the DataSet to change the datatype of the phone number field.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
AAGTHosting wrote:
Try studTableAdapter.Update(addRow)
Me thinks you didn't update the DataSet to change the datatype of the phone number field.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007I checked the dataSet and it says the phone number field is text. Also, when I try to do an insert the info does not get inserted into the database.
-
I checked the dataSet and it says the phone number field is text. Also, when I try to do an insert the info does not get inserted into the database.
AAGTHosting wrote:
I checked the dataSet and it says the phone number field is text.
Well, the code is throwing an exception that says otherwise. After changing the field type in the database, did you do ANYTHING to update the schema of the dataset?? If not, then it's not updated and it's still using an Integer type for one of those fields.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
AAGTHosting wrote:
I checked the dataSet and it says the phone number field is text.
Well, the code is throwing an exception that says otherwise. After changing the field type in the database, did you do ANYTHING to update the schema of the dataset?? If not, then it's not updated and it's still using an Integer type for one of those fields.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007I did update the schema of the dataset. In fact, when I tried to change the dataType in the designer it was already text.