日期:2014-05-19  浏览次数:20438 次

sql语句用了别名该如何用数据绑定?
在cx.cs中有如下面这段sql语句:
select   a.cc,a.fs,a.ds,b.fs,b.ds  
    from   table   a,table   b  
    where   a.name= 'aa '   and   b.name= 'bb '   and   a.no=b.no;
那么在cx.aspx中如何数据绑定呢?
DataBinder.Eval(Container.DataItem,?)
要将查询结果显示到页面,该如何写问号处的参数?

------解决方案--------------------
select a.cc,a.fs as fs_a,a.ds as ds_a,b.fs as fs_b,b.ds as ds_b
from table a,table b
where a.name= 'aa ' and b.name= 'bb ' and a.no=b.no;
------解决方案--------------------
select a.cc as acc,
a.fs as afs,
a.ds as ads,
b.fs as bfs,
b.ds as bds
from table a,table b
where a.name= 'aa ' and b.name= 'bb ' and a.no=b.no;

再绑定acc....
------解决方案--------------------
string search_str= "select a.station_train_code as cc,a.arrive_time as ft1,a.start_time as ft2,b.arrive_time as dt1,b.start_time as dt2 from stop_time a,stop_time b where a.station_name= ' "+sta_stop.Text+ " ' and b.station_name= ' "+end_stop.Text+ " ' and a.train_no=b.train_no ";


-----------
没看出问题来!
------解决方案--------------------
把绑定代码再帖出来看看,你确定sql没错?
------解决方案--------------------
应该没问题,你确定你用的sql就是 select a.station_train_code as cc .................. 是不是没有编译?????
------解决方案--------------------
你的数据表列名是啥,绑定时就用啥名
------解决方案--------------------
up
------解决方案--------------------
别名跟原来的名字一样用的 比如select * ,(select top 1 ##from table)as tt from table2 绑定的时候 绑定别名 呵呵~ 有别名就帮定别名

------解决方案--------------------
是别名就帮别名 帮顶 接分