请教!为什么删除完数据其他数据也查询不到了?

canylove canylove 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

关于以下代码,当我查询到数据,选择要删除的东西后,再查询数据时不出现任何东西,没有删除的数据也查询不到 只有把页面关掉重新查询才行 为什么? 请指教!!

 protected void Getdatabind()
{
Sda.SelectCommand = new SqlCommand();
Sda.SelectCommand.CommandTimeout = 180;
Sda.SelectCommand.Connection = con;
Sda.SelectCommand.CommandText = "LOTNO1";
Sda.SelectCommand.CommandType = CommandType.StoredProcedure;

Sda.SelectCommand.Parameters.Add(new SqlParameter("@FDATE", SqlDbType.Char)).Value = TxtDate.Text;
Sda.SelectCommand.Parameters.Add(new SqlParameter("@Class", SqlDbType.NVarChar)).Value = DDLClass.SelectedValue.Trim();



if (con.State.ToString() == "Closed")
con.Open();
Sda.Fill(Ds, "QTYLOT");
GridView1.DataSource = Ds.Tables["QTYLOT"].DefaultView;
GridView1.DataBind();

con.Close();

}
protected void Button2_Click(object sender, EventArgs e)
{
Sda.DeleteCommand = new SqlCommand();
Sda.DeleteCommand .Connection = con;
Sda.DeleteCommand .CommandType = CommandType.Text;
Sda.DeleteCommand .CommandText = "DELETE FROM ITEM WHERE LOTNO='" + txtlot.Text + "' ";
if (con.State.ToString() == "Closed")
con.Open();
//SqlDataReader sdr = Sda.DeleteCommand.ExecuteReader();
int p = Sda.DeleteCommand.ExecuteNonQuery();
//GridView1.DataSource = sdr;
//GridView1.DataBind();

con.Close();
if (txtlot.Text != "")
{
labAlert.Visible = true;
GridView1.Visible = false;
txtlot.Text = "";
}
//else
//{
//}

}


...全文

相关推荐

评论 26
收藏 已收藏
分享
返回顶部
canylove
.NET社区 62,275 成员 668,968 内容