如何使用c#在循环中向数据库插入多行 [英] How do I insert multiple rows to a database in a loop using c#

查看:96
本文介绍了如何使用c#在循环中向数据库插入多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下sql命令将一个已定义的行数插入表中



INSERT INTO table1(column1,column2)VALUES('1',' 2'),('3','4'),('5','6')



如何使用c#进行这样的查询没有定义行数。我想使用循环来添加由用户确定的列。我试着寻找解决方案,但无法得到一个可以理解的解决方案。任何形式的帮助将不胜感激

i have the following sql command which inserts a defined number of rows into a table

INSERT INTO table1(column1, column2) VALUES ('1','2'), ('3','4'), ('5','6')

how can i use c# to make such a query given that the number of rows are not defined. I would want to use a loop to add columns as determined by the user. I tried lookin for solutions but couldnt get an understandable one. Any form of help will be appreciated

推荐答案

检查出来:多种方式进行多次插入 [ ^ ]


这篇关于如何使用c#在循环中向数据库插入多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆