为什么记录下不移动 [英] Why record not moving next
本文介绍了为什么记录下不移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我点击下一个按钮时,它显示错误消息
Errot - 找不到表0
请帮忙。我的代码有什么问题。
When i click in Next Button it's showing Error Msg
Errot - Cannot find table 0
please help . what wrong in my code.
DataSet ds = new DataSet();
int i = 0;
private void display()
{
SqlConnection conn = new SqlConnection(@"Data Source=MANISH-PC\SQLEXPRESS;Initial Catalog=Leavemanagement;Integrated Security=True;Pooling=False");
conn.Open();
SqlCommand command = new SqlCommand("select * from Emp_Details", conn);
SqlDataReader dr = command.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
txtempid.Text = dr["ID"].ToString();
txtempname.Text = dr["Name"].ToString();
cbempsex.Text = dr["Sex"].ToString();
cbempcity.Text = dr["City"].ToString();
txtempmobile.Text = dr["MobileNo"].ToString();
txtempqulification.Text = dr["Qualification"].ToString();
cbempdep.Text = dr["Department"].ToString();
cbempdesg.Text = dr["Designation"].ToString();
txtempadd.Text = dr["Address"].ToString();
byte[] data = (byte[])dr["image"];
MemoryStream ms = new MemoryStream(data);
pictureBox1.Image = Image.FromStream(ms);
}
private void cmdnext_Click(object sender, EventArgs e)
{
if (i < ds.Tables[0].Rows.Count - 1)
{
i++;
display();
}
else
{
MessageBox.Show("No More");
}
}
推荐答案
你做什么?
with WHILE LOOP读取数据读取器中的所有记录并将其添加到数据集
what do you do?
with a WHILE LOOP read all records in data reader and add them to dataset
这篇关于为什么记录下不移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文