读书人

简单有关问题求救!实在没办法!搞不出出

发布时间: 2012-01-21 21:31:43 作者: rapoo

简单问题求救!!!!实在没办法!!!搞不出出问题的地方了???马上给分啊??????????
提示错误:标准表达式中数据类型不匹配
出错位置: Da.Fill(DS, "View ");
环境:VS2005+ACCESS2003 XP系统

小段代码:
public DataTable PostView(int PrdId)
{
DataSet DS = new DataSet();
try
{
MyConn = DB.CreateDB();
MyConn.Open();
OleDbCommand cmd2 = new OleDbCommand( "select orderid,title,content from product where id= ' " + PrdId + " ' ", MyConn);
OleDbDataAdapter Da = new OleDbDataAdapter();
Da.SelectCommand = cmd2;
Da.Fill(DS, "View ");


}
finally
{
MyConn.Close();
}
return DS.Tables[ "View "];


}

[解决办法]
标准表达式中数据类型不匹配

好像是,两个数据类型不一致时的错误提示,

楼主检查一下SQL记录集===> DATASET时,有没有从字符串到日期,或者确认下是否都可以转换成功,

有可能是数据格式错误,或者转换失败
[解决办法]
还有可能是,绑定时缺少某些字段!
[解决办法]
OleDbCommand cmd2 = new OleDbCommand( "select orderid,title,content from product where id= ' " + PrdId + " ' ", MyConn);

》》》


OleDbCommand cmd2 = new OleDbCommand( "select orderid,title,content from product where id= " + PrdId, MyConn);
[解决办法]
int PrdId ///int Type

OleDbCommand cmd2 = new OleDbCommand( "select orderid,title,content from product where id= ' " + PrdId + " ' ", MyConn);
/// string Type

[解决办法]
改成这样:
OleDbCommand cmd2 = new OleDbCommand( "select orderid,title,content from product where id= " + PrdId , MyConn);
就是把PrdId两边的单引号去掉,应该就行了。

读书人网 >asp.net

热点推荐