本文介绍了如果数据库中没有数据,则发出警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果数据库中没有产品或者没有产品可供显示,那么想显示没有要显示的产品。
怎么做。
这是我用来显示产品的代码
private void BindGridData()
{
try
{
con.Open();
string menuid =应用程序[ MenuId ]的ToString();
{
string sql = 从rsa_ProductItemTable中选择*,其中MenuId = + menuid;
SqlCommand cmd = new SqlCommand(sql,con);
SqlDataAdapter da = new SqlDataAdapter(sql,con);
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
}
}
catch (例外情况)
{
}
finally
{
con.Close();
}
}
请帮帮我。
解决方案
If no products exists in database or if there is no products to display, then wants to display like 'no products to display'.
How to do that.
This is the code i have used to display products
private void BindGridData() { try { con.Open(); string menuid = Application["MenuId"].ToString(); { string sql = "select * from rsa_ProductItemTable where MenuId=" + menuid; SqlCommand cmd = new SqlCommand(sql, con); SqlDataAdapter da = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); da.Fill(ds); DataList1.DataSource = ds; DataList1.DataBind(); } } catch (Exception ex) { } finally { con.Close(); } }
Please Help me with this.
解决方案
这篇关于如果数据库中没有数据,则发出警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!