一道关于C#一道程序问题!!很急!麻烦各位大侠给予帮助!在此谢谢你们了!
privatevoidbutton1_Click(objectsender,EventArgse){SqlConnectionconn=newSqlConnection(...
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn=new SqlConnection("Server=(local);Initial Catalog=db_test;Integrated Security=True");
conn.Open();
SqlCommand cmd=new SqlCommand();
cmd.Connection=conn;
cmd.CommandText="select * from tb_002";
SqlDataReader sdr=cmd.ExecuteReader();
while (sdr.Read())
{
listView1.Items.Add(sdr[1],ToString());
}
conn.Dispose();
button1.Enabled = false;
}
private void Form1_Load(object sender, EventArgs e)
{
}
此程序编写之后程序运行不了!显示错误!错误的语句是: listView1.Items.Add(sdr[1],ToString());
错误提示在此我附上图:
请各位大侠帮帮我,错在哪,怎么改成!真心感谢!!! 展开
{
SqlConnection conn=new SqlConnection("Server=(local);Initial Catalog=db_test;Integrated Security=True");
conn.Open();
SqlCommand cmd=new SqlCommand();
cmd.Connection=conn;
cmd.CommandText="select * from tb_002";
SqlDataReader sdr=cmd.ExecuteReader();
while (sdr.Read())
{
listView1.Items.Add(sdr[1],ToString());
}
conn.Dispose();
button1.Enabled = false;
}
private void Form1_Load(object sender, EventArgs e)
{
}
此程序编写之后程序运行不了!显示错误!错误的语句是: listView1.Items.Add(sdr[1],ToString());
错误提示在此我附上图:
请各位大侠帮帮我,错在哪,怎么改成!真心感谢!!! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询