rohitnet100
asked on
save new rows in grid
how can i insert only new rows from grid into database and only update the existing rows.
how to find which is new and which are existing rows ?
how to find which is new and which are existing rows ?
If you are updating using something like a DataAdapter then you just call the Update() method passing it your DataSet/DataTable. The DataAdapter will figure out for itself which rows require inserts and which require updates.
ASKER
can you send me a sample code, how to do this?
Very simplisticly:
Dim cn As New SqlConnection("Your connection string")
Dim adap As New SqlDataAdapter("SELECT SomeColumns FROM SomeTable", cn)
Dim dt As New DataTable()
adap.Fill(dt)
'// add some rows, change some rows, etc
'// commit the changes
adap.Update(dt)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.