try
{
SqlConnection con = new SqlConnection("workstation id=JWYABC;packet size=4096;user id=sa;data source=JWYABC;persist security info=False;initial catalog=fist1");
con.Open();
Int32 i;
Button[] button=new Button[100];
string sql="select cchj from wuliu_ruku where jz=1";\\选择jz=1的cchj(按钮的序号)
SqlCommand myCommand=new SqlCommand(sql,con);
SqlDataReader reader=myCommand.ExecuteReader();
while(reader.Read())\\循环读取数据 判断按钮背景色是否改变
{
i=Convert.ToInt32(reader.GetValue(0));
button[i].BackColor=Color.Red; \\错误处
}
reader.Close();
con.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
阿!~ 我黔驴技穷了 帮帮我吧 朋友们
[此贴子已经被作者于2006-5-16 13:52:35编辑过]