标准数据类型不匹配

jiangfan99 2007-12-04 05:06:00
string myConn1 = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '../../hx.mdb'";
OleDbConnection myConn = new OleDbConnection(myConn1);
myConn.Open();
string strselect = "select * from information where hx_id=" + “‘tx_id.Text’”;
OleDbCommand inst = new OleDbCommand(strselect, myConn);
OleDbDataReader reader;
reader = inst.ExecuteReader();

执行到ExecuteReader()提示标准数据类型不匹配,数据库中hx_id定义的是文本类型,数据库中有hx_id=123,而我在tx_id中输入123的时候,reader返回的是空,问题是在哪里??
...全文
115 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiangfan99 2007-12-04
  • 打赏
  • 举报
回复
谢谢,解决了
yqlvcxl_2007 2007-12-04
  • 打赏
  • 举报
回复
string strselect = "select * from information where hx_id=" + “‘tx_id.Text’”;
写错了
string strselect = "select * from information where hx_id='" + tx_id.Text+"'";
symbol441 2007-12-04
  • 打赏
  • 举报
回复

//怎么还是有全角符号

string strselect = string.Format("select * from information where hx_id='{0}'",tx_id,Text);

yqlvcxl_2007 2007-12-04
  • 打赏
  • 举报
回复
string strselect = "select * from information where hx_id=" + “‘tx_id.Text’”; 写错了
string strselect = "select * from information where hx_id='" + tx_id.Text+"'";
symbol441 2007-12-04
  • 打赏
  • 举报
回复



string strselect = "select * from information where hx_id='"+tx_id.Text+"’”;

ms44 2007-12-04
  • 打赏
  • 举报
回复
加个'在123两边。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧