求教,请帮忙看看是什么问题?
老是提示System.Data.SqlClient.SqlException: 在关键字 'select' 附近有语法错误。第 1 行: 'tab1' 附近有语法错误。
部分代码如下:
private void GetSqlData()
{//得到入库出库记录
string conStr = ConfigurationSettings.AppSettings["connString"];
SqlConnection cxconn=new SqlConnection( conStr);
string strsql="";
strsql="(select * from select tab1.giftname,tab1.in1,isnull(tab2.out1,0) as out2,(tab1.in1-isnull(tab2.out1,0)) as still_in ";
strsql+="from (select giftname,sum(giftenternum) as in1 from gift_entry as a where";
strsql+="(a.Entrytime BETWEEN '2007-03-01' AND '2008-03-01') AND ";
strsql+="(a.LayoutName = 'XXX') AND (a.Shop = 'XXX')";
strsql+="group by giftname) as tab1,";
strsql+="(select giftname,sum(giftnum) as out1 from gift_shipment as b where";
strsql+="(b.shipmentdate BETWEEN '2007-03-01' AND '2008-03-01') AND ";
strsql+="(b.LayoutName = 'XXX') AND (b.Shop = 'XXX' )";
strsql+="group by giftname) as tab2";
strsql+="where tab1.giftname*=tab2.giftname ) as tab3";
SqlDataAdapter dap = new SqlDataAdapter(strsql,cxconn);
cxconn.Open();
DataSet ds=new DataSet();
dap.Fill(ds,"tab3");
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
cxconn.Close();
}
请高手看看怎么解决,谢谢!!!