如何解决方法名称空间

编程入门 行业动态 更新时间:2024-10-24 18:25:16
本文介绍了如何解决方法名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

bool SQLExecuteBatch(string[] strQueryText) { bool Success = false; using (SqlConnection cnSQL = new SqlConnection(conStr)) { cnSQL.Open(); SqlCommand cmd = cnSQL.CreateCommand(); SqlTransaction stBatch; stBatch = cnSQL.BeginTransaction("SampleTransaction"); cmd.Connection = cnSQL; cmd.Transaction = stBatch; try { for (int i = 0; (i <= (strQueryText.Length - 1)); i++) { cmd.CommandText = strQueryText(i); cmd.ExecuteNonQuery(); } stBatch.Commit(); Success = true; } catch (Exception ex1) { Cursor.Current = Cursors.Default; MessageBox.Show(("SQLExecuteBatch request can not be performed due to the following..." + ("\r" + ("\r" + (ex1.Message + ("\r" + ("\r" + "Changes were not applied to the target data.")))))), "Database Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); try { stBatch.Rollback(); } catch (Exception ex2) { Cursor.Current = Cursors.Default; MessageBox.Show(("SQLExecuteBatch rollback attempt failed..." + ("\r" + ("\r" + ex2.Message))), "Database Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } Success = false; } } return true; }

我有问题strQueryText

im having problem strQueryText

for (int i = 0; (i <= (strQueryText.Length - 1)); i++) { cmd.CommandText = strQueryText(i); cmd.ExecuteNonQuery(); }

我的尝试: i已经尝试了我所知道的一切

What I have tried: i have tried everything i know

推荐答案

C#使用方括号进行数组索引,而不是舍入。尝试: C#uses square brackets for array indexing, not round. Try: cmd.CommandText = strQueryText[i];

更多推荐

如何解决方法名称空间

本文发布于:2023-05-28 12:33:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/320991.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file &#039;D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!