数据库兼容模式设置
我的sql语句是select * from Course where datediff(day,updatetime,getdate())>=30 and Type = @Type CourseTime like '%白天班%' ,在数据库可以查询出来,在vs中却报错。
"day" 不是可识别的表提示选项。如果它要作为表值函数的参数,请确保您的数据库兼容模式设置为 90。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: "day" 不是可识别的表提示选项。如果它要作为表值函数的参数,请确保您的数据库兼容模式设置为 90。
源错误:
行 227: catch (Exception ex)
行 228: {
行 229: throw ex;
行 230: }
行 231: finally
源文件: C:\Documents and Settings\Administrator\桌面\xiangmu\LSWeb\LSWebDAL\DBHelper.cs 行: 229
堆栈跟踪:
[SqlException (0x80131904): "day" 不是可识别的表提示选项。如果它要作为表值函数的参数,请确保您的数据库兼容模式设置为 90。]
LSWebDAL.DBHelper.GetDataTable(String sql, SqlParameter[] values) in C:\Documents and Settings\Administrator\桌面\xiangmu\LSWeb\LSWebDAL\DBHelper.cs:229
LSWebDAL.CourseService.GetAllCourseByTime(Int32 Period, Int32 Start, Int32 Price, Int32 typeid, String Name) in C:\Documents and Settings\Administrator\桌面\xiangmu\LSWeb\LSWebDAL\CourseService.cs:1228
LSWebBLL.CourseManager.GetAllCourseByTime(Int32 Period, Int32 Start, Int32 Price, Int32 typeid, String Name) in C:\Documents and Settings\Administrator\桌面\xiangmu\LSWeb\LSWebBLL\CourseManager.cs:215
[TargetInvocationException: 调用的目标发生了异常。]
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +71
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +261
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +488
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1247
System.Web.UI.WebControls.BaseDataList.GetData() +38
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +153
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +54
System.Web.UI.WebControls.BaseDataList.DataBind() +55
System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +60
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +44
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842