Multiple Insert statements in one connection

前端 未结 4 1722
南旧
南旧 2021-01-24 00:05

I need some tips on how to do this better, I am inserting multiple queries with using one connection.

I understand this is not good programming, especi

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 00:42

    It is not possible to execute multiple queries in on OledbCommand. You have 2 options here

    1. Make a stored procedure
    2. call them one by one.

    OR As you are inserting in only one table so In your case though you can Design your query like this (just an example)

    INSERT INTO ACH (rptid, tableid, name, amount, stat, create_date) 
    SELECT 1,1, 'Value3',2,2,DateTime.Now.ToString()
    UNION
    SELECT 1,1, 'Value3',2,2,DateTime.Now.ToString()
    UNION
    SELECT 1,1, 'Value3',2,2,DateTime.Now.ToString()
    UNION
    SELECT 1,1, 'Value3',2,2,DateTime.Now.ToString()
    

提交回复
热议问题