循环插入数据问题

tongling15 2007-08-17 11:24:43
for(int j=0 ; j < Rows; j++)
{
//生成随机字符串
for( int i=0; i < strLength; i++ )
{
strRandom +=aryChar[Rnd.Next( aryChar.Length )];
}

strRandom =strRandom+num;
string sql = "Insert into edu_card(card_id) values('"+strRandom+"')";
include.insertData(sql);
}

第二次循环的时候把上一次的值也插入进数据库了`
123
123asd
123asdert
那里出了问题?
...全文
124 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xray2005 2007-08-17
  • 打赏
  • 举报
回复
for(int j=0 ; j < Rows; j++)
{
strRandom=null;//或者0,看是什么类型
//生成随机字符串
for( int i=0; i < strLength; i++ )
{

strRandom +=aryChar[Rnd.Next( aryChar.Length )];
}

strRandom =strRandom+num;
string sql = "Insert into edu_card(card_id) values('"+strRandom+"')";
include.insertData(sql);
}
Tensionli 2007-08-17
  • 打赏
  • 举报
回复
j循环内先把strRandom清空。
zhchg6666 2007-08-17
  • 打赏
  • 举报
回复
up

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧