Batch Updates and Inserts?

  • Thread starter Thread starter John Rugo
  • Start date Start date
J

John Rugo

Hi All,
I need some advice. I have been using DATASETS for a while now to get
around a problem. I need to present data that can be selected on a form and
changed. Not just one record but perhaps a field in a thousand records. I
generally use a Stored Procedure in SQL that handles everything; but to
update or insert a lot of data the connection gets strangled from calling
executesql(update this record) and then do the next. That's why I use
Datasets because I update/insert into the dataset and then do an Update on
the DataAdapter which handles all the work.

I want to use just a DataReader to populate my forms. Is there some manner
of using a Transaction or other means to iterate through a list of records
on the screen and update, or insert new data?

Thanks,
John.
 
Hi John

John Rugo said:
Hi All,
I need some advice. I have been using DATASETS for a while now to get
around a problem. I need to present data that can be selected on a form and
changed. Not just one record but perhaps a field in a thousand records. I
generally use a Stored Procedure in SQL that handles everything; but to
update or insert a lot of data the connection gets strangled from calling
executesql(update this record) and then do the next. That's why I use
Datasets because I update/insert into the dataset and then do an Update on
the DataAdapter which handles all the work.

FYI DataAdapter issues commands for you - it does the same behind the
scenes.
I want to use just a DataReader to populate my forms. Is there some manner
of using a Transaction or other means to iterate through a list of records
on the screen and update, or insert new data?

Errr, what? Can you explain it a bit more?
 
Yes, The DataAdapter does the work for me; but, A DataSet is Slower and
takes up more memory then using a Forward-Read-Only DataReader. That's why
I don't want to use a DataSet unless I have to.

If I was going to update a single record to a SQL Server I would do the
following:

1. Create Parameters to send to the Stored procedure
2. Open a Connection to the Database
3. Pass the Parameters to the Stored Procedure
4. Close the connection.

You can't do this to a thousand records because the connection gets messed
up.

John.

"Miha Markic" <miha at rthand com> wrote in message
Hi John

John Rugo said:
Hi All,
I need some advice. I have been using DATASETS for a while now to get
around a problem. I need to present data that can be selected on a form and
changed. Not just one record but perhaps a field in a thousand records. I
generally use a Stored Procedure in SQL that handles everything; but to
update or insert a lot of data the connection gets strangled from calling
executesql(update this record) and then do the next. That's why I use
Datasets because I update/insert into the dataset and then do an Update on
the DataAdapter which handles all the work.

FYI DataAdapter issues commands for you - it does the same behind the
scenes.
I want to use just a DataReader to populate my forms. Is there some manner
of using a Transaction or other means to iterate through a list of records
on the screen and update, or insert new data?

Errr, what? Can you explain it a bit more?
 
Hi John,

John Rugo said:
Yes, The DataAdapter does the work for me; but, A DataSet is Slower and
takes up more memory then using a Forward-Read-Only DataReader. That's why
I don't want to use a DataSet unless I have to.

If I was going to update a single record to a SQL Server I would do the
following:

1. Create Parameters to send to the Stored procedure
2. Open a Connection to the Database
3. Pass the Parameters to the Stored Procedure
4. Close the connection.

You can't do this to a thousand records because the connection gets messed
up.

If this is the only problem you have then put connection opening outside the
loop and maybe add a transaction if you need it.
 
Back
Top