我先有2个表查出2个datatable如下
字段意思分别是
------ 日期 收入项目 现金 刷卡 流水号 门店 备注 操作员 string sql1 = "select c.cDate,c.cItem,c.cAmountCash,c.cAmountCredit,c.cNo,O.oName,c.cRe,e.eName from Consume c,Outlet o,Employee e where o.oNumber=c.cOutlet and c.cCashier=e.eNumber";
DataTable dt1 = BaseAccess.GetDataTable(sql1);string sql2 = "select p.pDate,'会员卡充值' 'pItem',p.pAmountCash,p.pAmountCredit,p.pNo,O.oName,p.pRe,e.eName from PrepaidRecords p,Outlet o,Employee e where o.oNumber=p.pOutlet and p.cCashier=e.eNumber";
DataTable dt2 = BaseAccess.GetDataTable(sql2);
请问如何操作 ,谢谢了
字段意思分别是
------ 日期 收入项目 现金 刷卡 流水号 门店 备注 操作员 string sql1 = "select c.cDate,c.cItem,c.cAmountCash,c.cAmountCredit,c.cNo,O.oName,c.cRe,e.eName from Consume c,Outlet o,Employee e where o.oNumber=c.cOutlet and c.cCashier=e.eNumber";
DataTable dt1 = BaseAccess.GetDataTable(sql1);string sql2 = "select p.pDate,'会员卡充值' 'pItem',p.pAmountCash,p.pAmountCredit,p.pNo,O.oName,p.pRe,e.eName from PrepaidRecords p,Outlet o,Employee e where o.oNumber=p.pOutlet and p.cCashier=e.eNumber";
DataTable dt2 = BaseAccess.GetDataTable(sql2);
请问如何操作 ,谢谢了
解决方案 »
- 我正在写一个大的图片网站,图片很多,里面的图片怎么分呢
- 关于多个项目共用模板的问题
- 使用用户登录IP比较数据库中该用户IP时出错~~大神速来~~~~~~~~~~~
- gridview绑定后的格式
- |M| 如何把一个HtmlTable 转换成一个DataTable 以便给GridView绑定 谢谢
- WEB用户控件的问题!!
- 原先开发网站使用的webapp模式,编译都通过的,现用website模式却不行
- jmail 有没有中文的使用说明书?
- 用showModalDialog打开的模式窗口中的标题栏能去掉吗?怎么去?如果不能去,怎么改标题?
- 如何让页面刷新时flash控件不闪烁
- 服务器 cache问题
- ASP.NET 源代码 怎么运行调试
DataTable Dt1=new DataTable();
DataTable Dt2=new DataTable();
Dt1.Merge(Dt2);
Dt1 is what you want
我要把数据合并了 一起显示 不是多搞出几列
union all
select p.pDate,'会员卡充值' 'pItem',p.pAmountCash,p.pAmountCredit,p.pNo,O.oName,p.pRe,e.eName from PrepaidRecords p,Outlet o,Employee e where o.oNumber=p.pOutlet and p.cCashier=e.eNumber
";
我咋这么死脑筋呢
就往datatable上想
为什么不在sql想办法呢 哎
继续等待 看还有没有好的方法
int count=dt1.Rows.Count;
for(int i=0;i<count;i++)
{
DataRow row=dt2.NewRow();
row[0]=dt1.Rows[i][0];
row[1]=dt1.Rows[i][1];
//……
dt2.Rows.Add(row);
}或者在查询的时候,用union all将结果查到一个dt中
也可以在原有的DataTable里添加列 在加入第二个表的数据
效率低太低,做一个压力测试就down了
最好的办法就是在数据库两条sql语句
union一下
sql1
union
sql2
字段对应就行了