473,322 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Dataset question?

Hi,
I am developing an ASP .NET 2.0 application with code behind in VB.
I have a dataset in which I have some data (1 table and around 200 rows) fetched from the Database.

Now my query is as follows:

I have to insert the value of this dataset to a table. I want to avoid using 200 insert statements (even in a loop). How can I achieve this efficiently.

I am thinking to create dynamic insert queries and appending them using StringBuilder.append() method. So than I have a big string containing all the insert statements, delimited by newline character. Then I am thinking of passing this long string to a Stored Procedure present in my SQL Server. By this method I will not have to hit database for every insert statement from my codebehind and all the insert statements will be executed from my stored procedure.

Is this a proper idea. Or I should use some other method.

Please let me know.

Thanks
Pawan
Mar 1 '08 #1
5 905
Hi Pawan

When you said "I have to insert the value of this dataset to a table", did you mean a database table? If so, are you (1) trying to update the databases with changes made by the user, or (2) are you transferring data from one table to another?

If (1), then only update the rows that have been changed. If (2), try transferring the data from within SQL Server, and try and avoid sending the data via .NET.
Mar 2 '08 #2
Plater
7,872 Expert 4TB
If you have an SqlDataAdapter (used to fill DataSet's nicely), you can supply UpdateCommand and InsertCommand to its properties and they will be fired as needed when data in the dataset changes.
Mar 3 '08 #3
If you are using MS SQL then you can try the SqlBulkCopy class.
I am using MS SQL Server.

Thanks for the reply.
Pawan
Mar 4 '08 #4
If you have an SqlDataAdapter (used to fill DataSet's nicely), you can supply UpdateCommand and InsertCommand to its properties and they will be fired as needed when data in the dataset changes.
Will this automatically insert/update the data in the dataset to the database?
Mar 4 '08 #5
Plater
7,872 Expert 4TB
Will this automatically insert/update the data in the dataset to the database?
Roughly. I believe there are events that fire (or are triggered), that you can attach a handler to, when it thinks it should be performing those INSERTs/UPDATEs.
Mar 4 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Simon Harvey | last post by:
Hi everyone, I was wondering if it is possible, to use SQL to return more than one table at a time into a dataset. I only know the basics of SQL and so I'm not sure if I'm just asking a stupid...
2
by: JS | last post by:
I'm trying to create a data layer and having problems returning a DataSet from my code that's in a class module. Please forgive me. I'm new to C# (VB'er). I decided to create my data layer in...
2
by: Simon Harvey | last post by:
Hi everyone, I was wondering if it is possible, to use SQL to return more than one table at a time into a dataset. I only know the basics of SQL and so I'm not sure if I'm just asking a stupid...
0
by: Mike | last post by:
Hi, I am trying to solve a problem with a DataSet issue I am having. In my app the user selects certain options and based on those options it goes out to the db to get data based on those...
15
by: JIM.H. | last post by:
Hello, Can I send a dataset as a parameter into stored procedure and import data to a table in the stored procedure? Thanks, Jim.
2
by: Jeff Brown | last post by:
OK i have came to the conclusion that since this app will be run on multiple computers that loading a complete database and then updating on exit is a moot point. I have tried several ideas...
4
by: markerussell | last post by:
I have a question, in that if i have an application is it better to have one dataset per data adapter, ie daCustomerTable -> dsCustomer, daOrders -> dsOrders etc. or to say have a couple of dataset...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
2
by: JT | last post by:
I have an SQL database with one table in it. I want to load the table into a DataSet, add new records to the DataSet, then commit the changes back to the database. Using C#.NET, the following...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.