Quantcast
Channel: How should I multiple insert multiple records? - Stack Overflow
Browsing all 12 articles
Browse latest View live

Answer by Tiger Galo for How should I multiple insert multiple records?

Consider using TransactionScope. Any connection and query execution inside the scope will automatically be wrapped into the transaction and all you need to do is call scope.Complete() at the end. If...

View Article



Answer by abhiroop mukherjee for How should I multiple insert multiple records?

Just format the query string to add all set of values to be inserted.Something like this -for (int i = 0; i < nimbusUserIds.Count; i++) { parameterValues[i] = $"(0, 0, SYSDATETIME(),0,...

View Article

Answer by Ian Boyd for How should I multiple insert multiple records?

The truly terrible way to do it is to execute each INSERT statement as its own batch:Batch 1:INSERT INTO Entries (id, name) VALUES (1, 'Ian Boyd);Batch 2:INSERT INTO Entries (id, name) VALUES (2,...

View Article

Answer by simaglei for How should I multiple insert multiple records?

Following up @Tim Mahy - There's two possible ways to feed SqlBulkCopy: a DataReader or via DataTable. Here the code for DataTable:DataTable dt = new DataTable();dt.Columns.Add(new DataColumn("Id",...

View Article

Answer by 0014 for How should I multiple insert multiple records?

You can directly insert a DataTable if it is created correctly.First make sure that the access table columns have the same column names and similar types. Then you can use this function which I believe...

View Article


Answer by Michael for How should I multiple insert multiple records?

ClsConectaBanco bd = new ClsConectaBanco();StringBuilder sb = new StringBuilder();sb.Append(" INSERT INTO FAT_BALANCETE ");sb.Append(" ([DT_LANCAMENTO] ");sb.Append(" ,[ID_LANCAMENTO_CONTABIL]...

View Article

Answer by premkumar for How should I multiple insert multiple records?

Stored procedure to insert multiple records using single insertion:ALTER PROCEDURE [dbo].[Ins]@i varchar(50),@n varchar(50),@a varchar(50),@i1 varchar(50),@n1 varchar(50),@a1 varchar(50),@i2...

View Article

Answer by Tim Mahy for How should I multiple insert multiple records?

When it are a lot of entries consider to use SqlBulkCopy. The performance is much faster than a series of single inserts.

View Article


Answer by AMissico for How should I multiple insert multiple records?

static void InsertSettings(IEnumerable<Entry> settings) { using (SqlConnection oConnection = new SqlConnection("Data Source=(local);Initial Catalog=Wip;Integrated Security=True")) {...

View Article


Answer by Giorgi for How should I multiple insert multiple records?

If I were you I would not use either of them.The disadvantage of the first one is that the parameter names might collide if there are same values in the list.The disadvantage of the second one is that...

View Article

Answer by Tim Schmelter for How should I multiple insert multiple records?

You should execute the command on every loop instead of building a huge command Text(btw,StringBuilder is made for this)The underlying Connection will not close and re-open for each loop, let the...

View Article

How should I multiple insert multiple records?

I have a class named Entry declared like this: class Entry{ string Id {get;set;} string Name {get;set;}} and then a method that will accept multiple such Entry objects for insertion into the database...

View Article
Browsing all 12 articles
Browse latest View live




Latest Images