本文介绍了如何在for循环中增加插入查询性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 请帮助我解决这个问题如何使用参数化查询快速插入for循环 < pre lang = c# > for( int i = 0; i < = 10000; i ++ ) { 字符串 qry = 插入演示(id,文本,姓名,年龄,地址)值(@ id,@ text,@ name,@ age,@ address) ; MySqlParameter idP = new MySqlParameter(@id,0); MySqlParameter textP = new MySqlParameter(@ text,slipno / 2012-13 /); MySqlParameter nameP = new MySqlParameter(@ name,Ram); MySqlParameter ageP = new MySqlParameter(@ age,33); MySqlParameter addressP = new MySqlParameter(@address,house no#01,new street,New delhi,India); MySqlParameter [] p = {idP,textP, nameP,AGEP,addressP}; MysqlHelper.executenonquery(connecionstring,qry,p); } 解决方案 该评论者得到了我的投票。是的我也可以使用 BULK INSERT 。如果您不想要BULK INSERT,那么构建单个查询&执行一次(检查以下链接)。 使用单个数据将多条记录插入MySQL查询 [ ^ ] Pls help me in this problemhow can i insert fast in for loop using paramertizered query<pre lang="c#">for(int i=0;i<=10000;i++){string qry="insert into demo(id,text,name,age,address)values(@id,@text,@name,@age,@address)";MySqlParameter idP=new MySqlParameter(@id",0);MySqlParameter textP=new MySqlParameter(@text,slipno/2012-13/);MySqlParameter nameP=new MySqlParameter(@name,Ram);MySqlParameter ageP=new MySqlParameter(@age,33);MySqlParameter addressP=new MySqlParameter(@address",house no#01,new street,New delhi,India);MySqlParameter[]p={idP,textP,nameP,ageP,addressP};MysqlHelper.executenonquery(connecionstring,qry,p);} 解决方案 That commenter got my vote. Yes I too go with BULK INSERT. If you don't want BULK INSERT then build single query & execute once(check the below link).Insert multiple records into MySQL with a single query[^] 这篇关于如何在for循环中增加插入查询性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-09 22:27