for(int i=0;i

moguiziziwenlong 2006-04-14 05:33:38
static ArrayList arl=new ArrayList();
private void button1_Click(object sender, System.EventArgs e)
{
string sql1="select * from 表1 where 条件1='名字1'";
string sql2="select * from 表2 where 条件1='地址2'";
string sql3="select * from 表3 where 条件1='性别3'";
arl.Add(sql1);
arl.Add(sql2);
arl.Add(sql3);
}

private void button2_Click(object sender, System.EventArgs e)
{
for(int i=0;i<arl.Count;i++)
{
MessageBox.Show( ? );
}
}
MessageBox.Show( ? ) 这里怎么吧 arl里面的 3句 select 语句完整的读出来??
如果button1_Click()点了两次 读出来的会是 sql1 2次 sql2 2次 sql3 2次了???
...全文
320 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
webwait 2006-04-15
  • 打赏
  • 举报
回复
同意楼上
aSalt 2006-04-15
  • 打赏
  • 举报
回复
tangyong12 2006-04-14
  • 打赏
  • 举报
回复
你在click里面要先把arraylist的变量清空:
static ArrayList arl=new ArrayList();
private void button1_Click(object sender, System.EventArgs e)
{
arl.Clear();//在这里加上这句
string sql1="select * from 表1 where 条件1='名字1'";
string sql2="select * from 表2 where 条件1='地址2'";
string sql3="select * from 表3 where 条件1='性别3'";
arl.Add(sql1);
arl.Add(sql2);
arl.Add(sql3);
}
xiehuanxie 2006-04-14
  • 打赏
  • 举报
回复
static ArrayList arl=new ArrayList();

这样button1_Click()点两次 读出的肯定是两次了.
Knight94 2006-04-14
  • 打赏
  • 举报
回复
Sample code as follow:
private string ReadQueryString( int Index )
{
if( Index >= 0 && Index < arl.Count )
return arl[i].ToString();
else
return null;
}

private void button2_Click(object sender, System.EventArgs e)
{
string strQuery = ReadQueryString( yourIndex );
if( null != strQuery )
MessageBox.Show( strQuery );
}
luhongming 2006-04-14
  • 打赏
  • 举报
回复
点两次,就要两个了。

110,534

社区成员

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

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

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