PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

Create Dataset Relationship with DataTables containing multiple primary keys

 
 
Geo Verna
Guest
Posts: n/a
 
      16th Jul 2003
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
 
Reply With Quote
 
 
 
 
Kathleen Dollard
Guest
Posts: n/a
 
      16th Jul 2003
Geo,

DataSet.Relations.Add...

Although DataSets don't support joins.

Kathleen


"Geo Verna" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
New Member
Join Date: Mar 2010
Posts: 1
 
      19th Mar 2010
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#
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset with Multiple Datatables =?Utf-8?B?Sm9obiBCYWlsZXk=?= Microsoft ASP .NET 0 5th Jun 2005 05:06 PM
Multiple DataTables in Dataset =?Utf-8?B?VmlzaA==?= Microsoft ADO .NET 8 13th Apr 2005 02:29 PM
Primary Keys in DataTables Brandon Owensby Microsoft Dot NET Framework 1 16th Jun 2004 10:45 PM
Dataset with multiple Datatables Microsoft ADO .NET 0 12th Apr 2004 06:05 PM
Dataset with multiple Datatables Microsoft C# .NET 0 12th Apr 2004 06:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:42 AM.