473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Is it possible to JOIN a Dataset table? ASP.NET

3
For example in my code i am calling three slqadapter and stored it into three dataset.

Dataset 1

Description Shift1
PRINT 2
MOUSE 3
MONITOR 1

dataset 2

Description Shift2
PRINT 1
MOUSE 1
MONITOR 1

dataset 3

Description Shift3
PRINT 2
MOUSE 3
MONITOR 4

I would like to view all three dataset into one datset and display it on a gridview.



Description Shift1 Shift2 Shift3
PRINT 2 1 2
MOUSE 3 1 3
MONITOR 1 1 4

I need all of your help. please provide me with some example codes.

Thank you in advance.
Oct 30 '08 #1
4 1709
jhardman
3,406 Expert 2GB
rkhiev,

I assume you are talking about ASP.NET since ASP has neither gridViews nor DataSet objects. The ASP forum is for "classic" ASP only. I will go ahead and move your question to the correct forum, but please post all .NET questions in the future into the .NET forum.

What you are asking to do is fairly easy and straight-forward programatically, but I'm not sure it is really the best solution. Anyway, it looks something like this:
Expand|Select|Wrap|Line Numbers
  1. myDataSet.Tables["myTable"].Columns.Add("Shift2", typeof(int))
  2. myDataSet.Tables["myTable"].Columns.Add("Shift3", typeof(int))
  3. for (int i = 0; i<myDataSet.Tables["myTable"].Rows.Count; i++)
  4.    {
  5.    myDataSet.Tables["myTable"].Rows[i]["Shift2"] = mySecondDS.Tables["myTable"].Rows[i]["Shift2"]
  6.    myDataSet.Tables["myTable"].Rows[i]["Shift3"] = myThirdDS.Tables["myTable"].Rows[i]["Shift3"]
  7.    }
  8.  
but it seems to me it would make more sense to list these fields:
Shift print mouse monitor
and these rows:
1 1 1 1
2 1 2 3
3 2 1 1

How is the data coming in?

Jared
Oct 31 '08 #2
rkhiev
3
thanks for the reply.. but the table you provided me is that a single sqlAdapter table or a dataset. sorry maybe i am not clear about my question.

i want to iterate through my dataset and delete all duplicate column and leave the value column and add into a newer column. for example
here is my result of my code:

this is my Dataset and it will look this in my gridview

Description ResultValue
Print 1
Monitor 1
Mouse 1
Keyboard 1
LCD 1
Print 2
Monitor 2
Mouse 2
Keyboard 2
LCD 2
Print 3
Monitor 3
Mouse 3
Keyboard 3
LCD 3


This is how i wanted the result to look like


Description ResultValue ResultValue ResultValue
Print 1 2 3
Monitor 1 2 3
Mouse 1 2 3
Keyboard 1 2 3
LCD 1 2 3

Thank you inadvance
Nov 3 '08 #3
rkhiev
3
I tried using your code

ds.Tables[0].Columns.Add("Shift2", typeof(int));
ds.Tables[0].Columns.Add("Shift3", typeof(int)) ;


for (int i = 0; i<ds.Tables[0].Rows.Count; i++)
{

ds.Tables[0].Rows[i]["Shift2"] = mySecondDS.Tables[0].Rows[i]["Shift2"];
ds.Tables[0].Rows[i]["Shift3"] = myThirdDS.Tables[0].Rows[i]["Shift3"];
}

but it gave me an error on line bolded

Column 'Shift2' does not belong to table Table.
Nov 3 '08 #4
Frinavale
9,735 Expert Mod 8TB
Check out this article on How to implement DataSet JOIN helper class in Visual C# .NET.

-Frinny
Nov 3 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: LL | last post by:
Hi, My sql join two table, how to call the fill method? thanks. string sqlStr = "select * from table1, table2"; SqlDataAdapter myCommand = new SqlDataAdapter(sqlStr, myConnection);DataSet...
5
by: Wing | last post by:
Hi all, I execute a stored procedure in my C# code, assign the result to the SqlDataReader object and display it with datagrid. the question I like to ask, is possible to edit the datagrid...
0
by: Gareth Stretch | last post by:
Hi Guys. i am using C#.net connecting to an Access database using OleDbConnection i am using the following select Statement to join 3 tables string strdvds = "SELECT dvd.name,...
0
by: Sky | last post by:
Hello: Have a nagging question about creating disconnected DataSet queries... If you have a table called INodes of 10,000 records, and a Table called Clients of again 10,000 and a table called...
2
by: Bennett Haselton | last post by:
I know how to create a DataAdapter that loads data from a data source into a table in a typed DataSet, and how to set the DataSource and DataMember properties of a DataGrid so that at run time it...
1
by: Gene Ariani | last post by:
I have one dataset that contains two DataTables: DataTable1: Customer_ID 1
4
by: DraguVaso | last post by:
Hi, For my VB.NET application I have the following situation: 2 tables on my SQL Server: tblAccounts and tblRules. For each Account there are many Rules (so tblRules is linked to my tblAccounts...
3
by: Dragon | last post by:
Can I Join two Data Table in Data set ?? Is it using the DataSet.Merge ? Any example ?
0
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005 and .net 2.0. I have used 2 DirectorySearchers to retrieve Active Directory data and put them into 2 separate dataset tables. I want to create a 3rd dataset table by using the...
2
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005 and .net 2.0 I used 2 DirectorySearchers to retrieve data from Active Directory and placed them in 2 dataset tables. I need to perform the SQL equuvakebt of join operation to...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.