How can we insert 100 records @ a time without using for loop into the databse
Answers were Sorted based on User's Feedback
Answer / answerme
If we need to copy data from one table to another we may
use "insert into" statement.
Please elaborate the qusetion, from where do we need to
insert the records?
|Is This Answer Correct ?||14 Yes||2 No|
Answer / raja
simply you can use sqlbulkcopy to copy entire set to
send datatable as a parameter to the stored procedure, in
SP simply u can merge the table with actual table.
|Is This Answer Correct ?||8 Yes||0 No|
Answer / vinodh kumar
if you are inserting values from another table. then you can use this.
insert into table name
select <columns> from <table1>
|Is This Answer Correct ?||4 Yes||0 No|
Answer / harshal parab
We can insert multiple records using a xml string.
This will also save the roundtrips to the database.
|Is This Answer Correct ?||0 Yes||0 No|
Answer / natraja
convert your data as XML and use OpenXML concept in your sp
|Is This Answer Correct ?||2 Yes||2 No|
Answer / sudhir
By use of SQLcommandbuilder, Sqldataadapter and Dataset u can direct update or insert whole datatable or dataset onto database by useinf sqldataadapter.update(datatable/dataset) method
|Is This Answer Correct ?||1 Yes||2 No|
Answer / varsha motwani
You can use "Update()" method of DataAdapter which will
DataAdapter.Update Method (System.Data.Common).
This will internally call loop for insertion and it will
hit the database evry time for each record.
Another way is to aceppt input as string and pass record in
form of XML and parse the XML in stored procedure and
|Is This Answer Correct ?||1 Yes||3 No|
Answer / kiran tukaram mandhare
or use while loop to insert those record
u can use file uploader to do this
as u can create a .csv file of those 100 records and just
upload this file in runtime and using button click event
just write the code using file stream reader to insert
those records into database
|Is This Answer Correct ?||1 Yes||7 No|
What is an expression in c#?
What do you mean by streamreader/streamwriter class in c#?
What is anonymous methods in c#?
What does string intern do?
why c# is pronounced as C-sharp instead of pronouncing it as C-hash? is there any technical reason behind it?
Why would you use a class property in c#?
About multi level and multiple inheritance how to achieve in .net ?
What are variables in c#?
I have 3 overloaded constructors in my class. In order to avoid making instance of the class do I need to make all constructors to private?
Is collection a data structure?
Write a program to create a user control with name and surname as data members and login as method and also the code to call it. (Hint use event delegates) Practical Example of Passing an Events to delegates
Are multiple data types stored in System.Array?