如何解决方法名称空间 [英] How do I solve method name space
本文介绍了如何解决方法名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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];
这篇关于如何解决方法名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文