Click to See Complete Forum and Search --> : Inserting Records in database using Dataset


kashif_82
07-17-2006, 12:01 PM
Hi, my ADO.NET skills are very weak so I dont even know if it is possible or no. Basically I know how to get the records from the database using a dataadapter, edit it, and then update it. What I am trying to do here is that I have a two datatables that are within a dataset. Let's just say that this dataset was received as a parameter, is it possible to update two tables in the database with the all the records in the tables from that dataset which is being passed as a parameter.
Something similar to this if my wording doesn't make any sense:

Private Sub_Insert(DS as DataSet)
dim dt0 as DataTable = ds.Tables(0)
dim dt1 as DataTable = ds.Tables(1)

'update Database
'Insert records in dbo.table0

'Insert records in dbo.table1

end sub


Edits: sorry just to add to it, this is for SQL Server as backend.

postmaster
07-17-2006, 10:12 PM
The SQLDataReader object is used to provide with a forward-only, read-only set of data(records). The forward-only means that we can loop through the records in only one direction. The read-only means the data can not be updated through the SQLDataReader object. Now we would like to complete the example to get all data from the Customers table

Dim conn as SQLConnection = New SQLConnection("server=yourSERVER;Database=Northwind;uid=USERID;pwd=PASSWORD;")

Dim sSQL as String = "SELECT * FROM Customers" (SQL Statement)
Dim cmd as SQLCommand = New SQLCommand(sSQL, conn)

conn.Open()

Dim dr as SQLDataReader = cmd.ExecuteReader()

We can use this set of data to display in DataGrid

DataGrid1.DataSource = dr
DataGrid1.DataBind()

conn.Close()

=========================

Find an example at http://www.programmingknowledge.com/


=======

kashif_82
07-17-2006, 11:06 PM
What you just said doesn't make any sense what so ever regarding what I asked for.