string[] strTxt = TextBox1.Text.Split("\n".ToCharArray());
int i = dal.deleteUser(strTxt); public int deleteUser(string[] strTxt)
{
string sql;
SqlParameter[] p;
for (int n = 0; n < strTxt.Length; n++)
{
sql = "delete from bx_users where username in( @strTxt" + n + ")";
command = getCommand(sql, conString);
p = new SqlParameter[] { new SqlParameter("strTxt" + n, strTxt[n]) };
command.Parameters.AddRange(p);
}
int i = command.ExecuteNonQuery();
con.Close();
return i;
}我这个功能是从多行文本框读取用户名,然后在数据库批量删除用户。 请问为什么我这个方法只删除了最后一个用户?
请大家帮帮忙,如果能提供些批量数据处理的资料或实例最好不过了。
int i = dal.deleteUser(strTxt); public int deleteUser(string[] strTxt)
{
string sql;
SqlParameter[] p;
for (int n = 0; n < strTxt.Length; n++)
{
sql = "delete from bx_users where username in( @strTxt" + n + ")";
command = getCommand(sql, conString);
p = new SqlParameter[] { new SqlParameter("strTxt" + n, strTxt[n]) };
command.Parameters.AddRange(p);
}
int i = command.ExecuteNonQuery();
con.Close();
return i;
}我这个功能是从多行文本框读取用户名,然后在数据库批量删除用户。 请问为什么我这个方法只删除了最后一个用户?
请大家帮帮忙,如果能提供些批量数据处理的资料或实例最好不过了。
解决方案 »
- 加控件
- 求学jQuery入门到熟悉的资源,书
- 怎样写 mysql 自定义分页
- 关于线程的问题,疑惑,谢谢
- ■■无限级分类如何用递归和Repeater控件把所有分类按层次一次过显示出来?
- Devpartner菜单下的Start with Error Detection运行报错
- 高分求用友本部的U8面试.net工程师的题
- 怎样打开别人写的asp.net程序啊?
- 求救:The 'Microsoft.Jet.OLEDB4.0' provider is not registered on the local machine.
- 怎样在.NET中用c#发E-mail啊?高分请教。最好有示例。
- js提交Controller/action,可以断点吗?
- 到底怎么办
放到循环里面
int i = dal.deleteUser(strTxt); public int deleteUser(string[] strTxt)
{
string sql;
SqlParameter[] p;
for (int n = 0; n < strTxt.Length; n++)
{
sql = "delete from bx_users where username in( @strTxt" + n + ")";
command = getCommand(sql, conString);
p = new SqlParameter[] { new SqlParameter("strTxt" + n, strTxt[n]) };
command.Parameters.AddRange(p);
int i = command.ExecuteNonQuery();
}
con.Close();
return i;
}