当前位置: 代码迷 >> ASP.NET >> sql语句有关问题
  详细解决方案

sql语句有关问题

热度:6313   发布时间:2013-02-26 00:00:00.0
sql语句问题?
txt_state_rk和   txt_style_rk   是   txtbox

string   ztai   =   txt_state_rk.Text;
string   xinghao   =   txt_style_rk.Text;

string   sql   =   "select   *   from   cangkulingjian   where   ztailj   =   ztai   and   nolj   =   xinghao   ";

这样能找到相关数据吗
但是提示有异常
System.Data.OleDb.OleDbException:   至少一个参数没有被指定值。

------解决方案--------------------------------------------------------
字段名或者表名写错了。
------解决方案--------------------------------------------------------
string sql = "select * from cangkulingjian where ztailj = ' "
+ ztai + " ' and nolj = ' " + xinghao + " ' ";
------解决方案--------------------------------------------------------
string sql = "select * from cangkulingjian where ztailj = ztai and nolj = xinghao ";改为
string sql = "select * from cangkulingjian where ztailj = ' "+ ztai+ " ' and nolj = ' "+ xinghao+ " ' ";
  相关解决方案