存储过程循环 [英] stored procedure in loop

查看:69
本文介绍了存储过程循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一种在循环中编写存储过程的有效方法吗?



is this efficient way of writing the stored procedure in a loop??

for (int i = 0; i < purchaseListView.Items.Count; i++)
                     {
Connection con = new Connection();
                     SqlCommand cmd = new SqlCommand();
                     SqlCommand cmdFifo = new SqlCommand();
                     con.OpenConnection();
                     cmd.Connection = con.DataBaseConnection;
                     cmd.CommandType = CommandType.StoredProcedure;
                     cmd.CommandText = "insertDetail";
                     cmdFifo.Connection = con.DataBaseConnection;
                     cmdFifo.CommandType = CommandType.StoredProcedure;
                     cmdFifo.CommandText = "insertInToMain";



请让我知道循环存储过程的正确方法

最好的问候

bunzitop


please let me know the right way of looping the stored procedure
best regards
bunzitop

推荐答案

不,因为你一次又一次地打开连接。在循环之外,打开连接。
No, because you open the connection again and again and again. Outside your loop, open the connection.


这篇关于存储过程循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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