求求各位大虾,帮我看看下面这个在ASP.NET里的SQL语句,,哪里错了?谢谢!!
1-》if(IsNumberic(tb_sj.Text)==true){this.tb_sj.Text=string.Format("{0:F0}",Convert.To...
1-》
if (IsNumberic(tb_sj.Text) == true) { this.tb_sj.Text = string.Format("{0:F0}", Convert.ToDouble(tb_sj.Text)); Etextbox("Dplansell", "DPSSJ", tb_sj.Text, "DPSdatetime",lbldate.Text); } else { Response.Write("<script>alert(' 抱歉!只能输入数字!')</script>"); this.tb_sj.Text = ""; this.tb_sj.Focus(); }
2-》
public void Etextbox(string Stable,string Stextbox,string strtbox,string Sdatetime,string strdate) { //根据日期查询是否有数据存在!! string sql = "select * from '" + Stable + "' where '" + Sdatetime + "'='" + strdate + "'"; SqlConnection con = pub.createCon(); con.Open(); SqlCommand com = new SqlCommand(); com.Connection = con; com.CommandText = sql; SqlDataReader dr = com.ExecuteReader(); 展开
if (IsNumberic(tb_sj.Text) == true) { this.tb_sj.Text = string.Format("{0:F0}", Convert.ToDouble(tb_sj.Text)); Etextbox("Dplansell", "DPSSJ", tb_sj.Text, "DPSdatetime",lbldate.Text); } else { Response.Write("<script>alert(' 抱歉!只能输入数字!')</script>"); this.tb_sj.Text = ""; this.tb_sj.Focus(); }
2-》
public void Etextbox(string Stable,string Stextbox,string strtbox,string Sdatetime,string strdate) { //根据日期查询是否有数据存在!! string sql = "select * from '" + Stable + "' where '" + Sdatetime + "'='" + strdate + "'"; SqlConnection con = pub.createCon(); con.Open(); SqlCommand com = new SqlCommand(); com.Connection = con; com.CommandText = sql; SqlDataReader dr = com.ExecuteReader(); 展开
3个回答
展开全部
string sql = "select * from '" + Stable + "' where '" + Sdatetime + "'='" + strdate + "'";
改成
string sql = "select * from " + Stable + " where " + Sdatetime + "='" + strdate + "'";
或者 这样更清新
string sql = string.Format("select * from {0} where {1} = '{2}'", Stable, Sdatetime, strdate);
改成
string sql = "select * from " + Stable + " where " + Sdatetime + "='" + strdate + "'";
或者 这样更清新
string sql = string.Format("select * from {0} where {1} = '{2}'", Stable, Sdatetime, strdate);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
from table 的 table 无需引号
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询