Reputation: 11
Dim newRow As DataRow = dt.NewRow
newRow.Item(1) = Student_IDTextBox.Text
newRow.Item(2) = Student_NameTextBox.Text
newRow.Item(3) = Date_of_BirthDateTimePicker.Text
newRow.Item(4) = AddressTextBox.Text
newRow.Item(5) = E_mailTextBox.Text
newRow.Item(6) = AllergiesTextBox.Text
newRow.Item(7) = Emergency_Contact_NumberTextBox.Text
dt.Rows.Add(newRow)
The line
newRow.Item(2) = Student_NameTextBox.Text
gives a error saying:
"String was not recognized as a valid DateTime. Couldn't store <> in Date of Birth Column. Expected type is DateTime."
But I checked the database the second row is the Student name Field.
I think the code is starting to input the student name into the student ID field in the database, The Student Id is the primary key coe this be why it isn't storing the student_IDtextbox
data in its specified field?
I realy need help with this my project is due in about 9 days!
Upvotes: 0
Views: 234
Reputation: 6481
the columns index in DataRow class, Similar all indexs in vb.net, its zero-based. first column is zero, second one and ect.
Upvotes: 1