两个数据库:A,B;
数据库A中的表T有字段t1,t2,tf;
数据库B中的表F有字段tf,f2,f3;
(根据tf可以把两个表联合起来)已知:绑定A中表T的数据如下:string sql = "SELECT * from T";
DataSet ds= SqlHelper.ExecuteAdapter(SqlHelper.ConnA, CommandType.Text, sql, null);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();绑定B中表F的数据如下:string sql = "SELECT * from F";
DataSet ds= SqlHelper.ExecuteAdapter(SqlHelper.ConnB, CommandType.Text, sql, null);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();现在要把他们联合起来到一个DataSet里面,该怎么办?
数据库A中的表T有字段t1,t2,tf;
数据库B中的表F有字段tf,f2,f3;
(根据tf可以把两个表联合起来)已知:绑定A中表T的数据如下:string sql = "SELECT * from T";
DataSet ds= SqlHelper.ExecuteAdapter(SqlHelper.ConnA, CommandType.Text, sql, null);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();绑定B中表F的数据如下:string sql = "SELECT * from F";
DataSet ds= SqlHelper.ExecuteAdapter(SqlHelper.ConnB, CommandType.Text, sql, null);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();现在要把他们联合起来到一个DataSet里面,该怎么办?
http://www.cnblogs.com/notus/archive/2006/06/26/435851.html
填充DataSet数据集的几种方式 :
http://www.cnblogs.com/liulanglang/archive/2007/07/08/810019.html
DataSet ds= SqlHelper.ExecuteAdapter(SqlHelper.ConnB, CommandType.Text, sql, null);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
select a.t1,a.t2,a.tf,b.f2,b.f3 from a..t a,b..f b where a.tf=b.tf
不对呀,你们没看清题目,是两个数据库的两张表,连接第一个数据库用ConnA,连接第二个 数据库用ConnB,用一个SQL语句肯定是不行!
select a.t1,a.t2,a.tf,b.f2,b.f3 from a..t a,b..f b where a.tf=b.tf
上线后可能是放在两台上,访问数据库A要用连接字符串ConnA,访问数据库B要用连接字符串ConnB。
参考一下这个:
http://blog.csdn.net/sdhdy/archive/2009/05/25/4215311.aspx