数据类型不匹配
标准表达式中数据类型不匹配。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息:
System.Data.OleDb.OleDbException: 标准表达式中数据类型不匹配。
源错误:
行 27: OleDbDataAdapter myCommand = new OleDbDataAdapter( "SELECT * FROM aa WHERE id= ' "+newsid+ " ' ", myConnection);
行 28: DataSet ds = new DataSet();
行 29: myCommand.Fill(ds, "aa ");
行 30: dr = ds.Tables[ "aa "].Rows[0];
行 31:
[OleDbException (0x80040e07): 标准表达式中数据类型不匹配。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +177
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +56
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +105
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +91
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +4
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +140
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
www.MyCodeBehind.Page_Load(Object sender, EventArgs e) in g:\Applications\MyNews\xiu.cs:29
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3743
我用的是ACCESS数据库
------解决方案--------------------OleDbDataAdapter myCommand = new OleDbDataAdapter( "SELECT * FROM aa WHERE id= "+newsid.ToString(), myConnection);
试试
------解决方案--------------------i see
你的id 肯定是数字字段的 因此在access中
SELECT * FROM aa WHERE id= '1 ' 是错误的
应该是 SELECT * FROM aa WHERE id = 1
------解决方案----