S
stephen
Hi,
I know that you can pass 2 query strings into a dataadapter and fill a
dataset with 2 tables like this:
System.Data.SqlClient.SqlConnection con = new
System.Data.SqlClient.SqlConnection(Conn);
System.Data.SqlClient.SqlDataAdapter sda1 =
new System.Data.SqlClient.SqlDataAdapter("select ShipperID, CompanyName,
Phone, RegionDescription " +
"from shippers", con);
System.Data.SqlClient.SqlDataAdapter sda2 =
new System.Data.SqlClient.SqlDataAdapter("SELECT EmployeeID, lastname,
firstname " +
"FROM Employees", con);
sda1.Fill(ds, "TableShippers");
sda2.Fill(ds, "TableEmployees");
and use it like grid1.datasource = ds.tables["TableShippers"] or
ds.tables["TableEmployees"]
........
but i came accross an interesting code (pretty sweet...) that instead of 2
adapters you can pass the 2 queries in the same adapter and it works
System.Data.SqlClient.SqlConnection con = new
System.Data.SqlClient.SqlConnection(Conn);
System.Data.SqlClient.SqlDataAdapter sda =
new System.Data.SqlClient.SqlDataAdapter("select ShipperID, CompanyName,
Phone, RegionDescription " +
"from shippers;" +
"SELECT EmployeeID, lastname, firstname FROM Employees",
con);
if I use it like this grid1.datasource = ds.tables[0] or ds.tables[1] it
displays the appropriate data but if i use
ds.tables["TableShippers"] or ds.tables["TableEmployees"] if always binds to
ds.tables["TableShippers"]
why? and how can i use it by given table names?
I tried
sda.Fill(ds, "TableShippers");
sda.Fill(ds, "TableEmployees");
(...felt this syntax is not right but still defaults to shippers....)
Any ideas,
Stephen
I know that you can pass 2 query strings into a dataadapter and fill a
dataset with 2 tables like this:
System.Data.SqlClient.SqlConnection con = new
System.Data.SqlClient.SqlConnection(Conn);
System.Data.SqlClient.SqlDataAdapter sda1 =
new System.Data.SqlClient.SqlDataAdapter("select ShipperID, CompanyName,
Phone, RegionDescription " +
"from shippers", con);
System.Data.SqlClient.SqlDataAdapter sda2 =
new System.Data.SqlClient.SqlDataAdapter("SELECT EmployeeID, lastname,
firstname " +
"FROM Employees", con);
sda1.Fill(ds, "TableShippers");
sda2.Fill(ds, "TableEmployees");
and use it like grid1.datasource = ds.tables["TableShippers"] or
ds.tables["TableEmployees"]
........
but i came accross an interesting code (pretty sweet...) that instead of 2
adapters you can pass the 2 queries in the same adapter and it works
System.Data.SqlClient.SqlConnection con = new
System.Data.SqlClient.SqlConnection(Conn);
System.Data.SqlClient.SqlDataAdapter sda =
new System.Data.SqlClient.SqlDataAdapter("select ShipperID, CompanyName,
Phone, RegionDescription " +
"from shippers;" +
"SELECT EmployeeID, lastname, firstname FROM Employees",
con);
if I use it like this grid1.datasource = ds.tables[0] or ds.tables[1] it
displays the appropriate data but if i use
ds.tables["TableShippers"] or ds.tables["TableEmployees"] if always binds to
ds.tables["TableShippers"]
why? and how can i use it by given table names?
I tried
sda.Fill(ds, "TableShippers");
sda.Fill(ds, "TableEmployees");
(...felt this syntax is not right but still defaults to shippers....)
Any ideas,
Stephen