主题:大虾请帮忙..
string strconn=ConfigurationSettings.AppSettings["dsn"];
SqlConnection cn=new SqlConnection(strconn);
string orderstate="Select RID,RType,TID,TName,ORID,OBeginDate,OEndDate,OPay FROM GuestRoom,RoomType,Occupy where RID=ORID AND RType=TID AND OPay!=0";
if(ddl_rtype.SelectedItem.Value.ToString()!="-1")
{
orderstate=orderstate+"and rtype"+ddl_rtype.SelectedItem.Value.ToString();
}
string datefrom=ddl_yearfrom.SelectedItem.Value.ToString()+"-"+ddl_monthfrom.SelectedItem.Value.ToString()+"-"+ddl_dayfrom.SelectedItem.Value.ToString();
string dateto=ddl_yearto.SelectedItem.Value.ToString()+"-"+ddl_monthto.SelectedItem.Value.ToString()+"-"+ddl_dayto.SelectedItem.Value.ToString();
orderstate=orderstate+"and ordersdate between '"+datefrom+"'and'"+dateto+"'";
SqlDataAdapter da=new SqlDataAdapter(orderstate,cn);
DataSet ds=new DataSet();
da.Fill(ds);
dgd_count.DataSource=ds;
dgd_count.DataBind();
cn.Close();
错误信息:
第 1 行: 'ordersdate' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: 'ordersdate' 附近有语法错误。
源错误:
行 107: SqlDataAdapter da=new SqlDataAdapter(orderstate,cn);
行 108: DataSet ds=new DataSet();
行 109: da.Fill(ds);
行 110: dgd_count.DataSource=ds;
行 111: dgd_count.DataBind();
源文件: c:\inetpub\wwwroot\hotel\turnovercount.aspx.cs 行: 109
堆栈跟踪:
[SqlException: 第 1 行: 'ordersdate' 附近有语法错误。]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) +44
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +5
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
hotel.TurnoverCount.BindGrid() in c:\inetpub\wwwroot\hotel\turnovercount.aspx.cs:109
hotel.TurnoverCount.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\hotel\turnovercount.aspx.cs:54
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
SqlConnection cn=new SqlConnection(strconn);
string orderstate="Select RID,RType,TID,TName,ORID,OBeginDate,OEndDate,OPay FROM GuestRoom,RoomType,Occupy where RID=ORID AND RType=TID AND OPay!=0";
if(ddl_rtype.SelectedItem.Value.ToString()!="-1")
{
orderstate=orderstate+"and rtype"+ddl_rtype.SelectedItem.Value.ToString();
}
string datefrom=ddl_yearfrom.SelectedItem.Value.ToString()+"-"+ddl_monthfrom.SelectedItem.Value.ToString()+"-"+ddl_dayfrom.SelectedItem.Value.ToString();
string dateto=ddl_yearto.SelectedItem.Value.ToString()+"-"+ddl_monthto.SelectedItem.Value.ToString()+"-"+ddl_dayto.SelectedItem.Value.ToString();
orderstate=orderstate+"and ordersdate between '"+datefrom+"'and'"+dateto+"'";
SqlDataAdapter da=new SqlDataAdapter(orderstate,cn);
DataSet ds=new DataSet();
da.Fill(ds);
dgd_count.DataSource=ds;
dgd_count.DataBind();
cn.Close();
错误信息:
第 1 行: 'ordersdate' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: 'ordersdate' 附近有语法错误。
源错误:
行 107: SqlDataAdapter da=new SqlDataAdapter(orderstate,cn);
行 108: DataSet ds=new DataSet();
行 109: da.Fill(ds);
行 110: dgd_count.DataSource=ds;
行 111: dgd_count.DataBind();
源文件: c:\inetpub\wwwroot\hotel\turnovercount.aspx.cs 行: 109
堆栈跟踪:
[SqlException: 第 1 行: 'ordersdate' 附近有语法错误。]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) +44
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +5
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
hotel.TurnoverCount.BindGrid() in c:\inetpub\wwwroot\hotel\turnovercount.aspx.cs:109
hotel.TurnoverCount.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\hotel\turnovercount.aspx.cs:54
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731