I am trying to write some rows from one table onto a second table. The ID field in the original table is an autonumber, the field in the second table is just a regular integer. The code I've written copies all of the information over including the value of the ID field.
When I display the new table in datagridview, I can see that for all nine rows of the new field there is a value in the ID field. However, when I go to update the database, I'm told that "Cannot insert the value NULL into column 'ID', table tables.dbo.NewTable'; column does not allow nulls. INSERT fails."
Here is an example of my code
Expand|Select|Wrap|Line Numbers
- For i As Integer = 0 To Table.Rows.Count - 1
- Dim row1 As DataRow 'Initialized row
- row1 = .NewTable.NewNewTableRow() 'Tells the program what table the row will belong to
- 'Fills in user information into the imaginary row
- row1("ID") = .Table.Rows(i).Item("ID")
- row1("Description") = .Table.Rows(i).Item("Description")
- row1("Note") = .Tabler.Rows(i).Item("Note")
- row1("StartDate") = .Table.Rows(i).Item("StartDate")
- row1("EndDate") = .Table.Rows(i).Item("EndDate")
- row1("Term") = .Table.Rows(i).Item("Term")
- row1("Contact") = .Table.Rows(i).Item("Contact")
- row1("ContactType") = .Table.Rows(i).Item("ContactType")
- row1("OwnerID") = .Table.Rows(i).Item("OwnerID")
- .NewTable.Rows.Add(row1)
- Next
- NewTableTableAdapter.Update(.NewTable)
Has anyone seen anything like this, or have any ideas on what could be causing this. As far as I can tell, there are no null values for ID.