Disconected Dataset & dataTable

G

Guest

Hi everybody,

I have datatable and stored in dataset. The dataset Never connect to datasource before. How can I move mydata in dataset into the table in data souce? For instance my table say it Temp_table have fields EmpID, Name and age and my Table in datasource, say it Origin_Table have the same field. Then I add 5 data into Temp_Table. I want 5 data move into origin_table at the same time.

Is there some one want to help me, please?
 
J

John Saunders

Wance said:
Hi everybody,

I have datatable and stored in dataset. The dataset Never connect to
datasource before. How can I move mydata in dataset into the table in data
souce? For instance my table say it Temp_table have fields EmpID, Name and
age and my Table in datasource, say it Origin_Table have the same field.
Then I add 5 data into Temp_Table. I want 5 data move into origin_table at
the same time.

You would use the exact same technique you would have used if the DataSet
had originally been filled from the database: use a DataAdapter and use the
Update method of the DataAdapter.
 
G

Guest

John,

Thank for your response, but I am still confused how to work with
disconected data. I 've created disconected dataset and table. Then I create
DataGrid to display data that added in form. If finish add data, I want to
send data to table in SQL Server database. My Table in SQL Server have
automatic number field. Say it "GatepassID", but in my disconected table I
don't give the "gatepassID" value, cause it will generate by SQL Server when
I update data from disconected table to table in SQL Server.

I want after user add data into disconected table and store into SQL Table
they will get new number ("gatepassID") generated by SQL so the data will
always consistence.

how method should I make?

Thank and Regards


wawan
 
J

John Saunders

I'm on the run, so don't have time for a better answer right now:

I've seen code where the disconnected table has the "ID" field defined as
autonumber(-1,-1) even though it's defined as autonumber(1,1) in the
database. This way, while disconnected, you'll get ID numbers in a totally
different range from the real ones in the database.

These will be ignored when you update to the database, and replaced with the
real, positive ID numbers.

There is some trick I'll need to look up, which reads back the "final" ID
values after the update is done to the database, and updates the in-memory
table with the "real" value. Apparently, it can also update any related
in-memory tables as well. I'll try to dig that up for you, but it may take a
day or so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top