Create Dataset Relationship with DataTables containing multiple primary keys

  • Thread starter Thread starter Geo Verna
  • Start date Start date
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
 
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

Back
Top