Create Dataset Relationship with DataTables containing multiple primary keys

G

Geo Verna

I am trying to create a Dataset Relationship with two DataTables that
contain two primary keys. The reason for the dataset relationship is
to perform a JOIN on two tables from two different database servers.
Please find my code below. Any help would be appreciated.

cn.ConnectionString = oData.GetConnectionString_TA();
sc.CommandText = "SELECT ClientCode, UserID, USERPW FROM Users
WHERE ClientCode IN (" + strClientCodeList + ")";

sc.CommandType = CommandType.Text;
sc.Connection = cn;

da.SelectCommand = sc;

ds.Clear();
da.Fill(ds,"TA_Users");

cn.ConnectionString = oData.GetConnectionString_TRe();
sc.CommandText = "SELECT ClientCode, UserID, Group, UserName FROM
Add_User";
sc.CommandType = CommandType.Text;
sc.Connection = cn;

ds.Clear();
da.Fill(ds,"MC_Users");

ds.Relations.Add("TA_MC_Users",ds.Tables["TA_Users"].Columns["ClientCode"],
ds.Tables["MC_Users"].Columns["ClientCode"]);

The tables are set up so that both "ClientCode" and "UserID" are the
primary keys.

Thank you
Geo
 
K

Kathleen Dollard

Geo,

DataSet.Relations.Add...

Although DataSets don't support joins.

Kathleen
 
Joined
Mar 19, 2010
Messages
1
Reaction score
0
its easy to bind data to treeview upto one child but its diffficult to create subchild to child can u help me out this in c#
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top