1
Answer

How to insert a row with a column with an auto increase

marcodev

marcodev

20y
1.7k
1
i have a table with 2 column with this scheme: ID | Name ID = counter primary key Name = text i use this code to add new rows in the table. But for the first item newRow("ID") it is a counter so it auto increase itself. I have no to update. But if i don't i get error. Dim newRow As DataRow newRow = global.ds.Tables(0).NewRow newRow("ID") = ?????? newRow("Nome") = txbNome.Text global.ds.Tables(0).Rows.Add(newRow) global.da.Update(global.ds, "myTable") How can add a new row and leave the system database handle the ID column?
Answers (1)
0
eksypnos123

eksypnos123

NA 65 0 20y
Much easier to create an insert command object and then run it using executeNonQuery() You just set the value for the Name, ID will be handled by the database. and by the way, this is C# forum, so what's this Dim overthere?