0
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!

1 Answer 1

1

the columns index in DataRow class, Similar all indexs in vb.net, its zero-based. first column is zero, second one and ect.

Sign up to request clarification or add additional context in comments.

2 Comments

Also, because you used SELECT *, you are not guaranteed to order of your fields, you should spell out your field names in your select. IE, SELECT ID,Student_Name,Etc.. FROM ...
Thank you, that seems to be working nw but another line has given me yet another error: da.Update(dt)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.