473,386 Members | 1,720 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,386 software developers and data experts.

asp.net sql join

Hallo Everyone,

I am using sql dataset and tableadapter to fill data into the gridview using object data source. i have 3 database table

statistik
------------
date client container charges password
26.04.10 testing 20 100 test1
25.04.10 testing 40 100 test1
25.04.10 newtester 40 150 sre

contact
------------
matchcode firstname lastname customerpassword
testhamb jen hansen test1
newtest tester sre
testhamb anna fletcher testing

Address
------------

matchcode client city

testhamb testing hamburg
testbrem testing bremen
newtest newtester Bonn

Now i have to populate resultset into gridview like this

Date client city container charges

26.04.10 testing hamburg 20 100 test1
25.04.10 testing hamburg 40 100 test1
25.04.10 newtester Bonn 40 150 sre

first i have to match with the password and then take the matchcode and then match with the matchcode in the address table. how can do this any idea ?.. left outer join is not working out.
Apr 27 '10 #1
5 2604
Frinavale
9,735 Expert Mod 8TB
Are you having problems displaying the data or getting it?

-Frinny
Apr 27 '10 #2
@Frinavale
Hallo Frinavale,

I am having problem getting the data.. i need populate like this

Now i have to populate resultset into gridview like this

Date client city container charges

26.04.10 testing hamburg 20 100 test1
25.04.10 testing hamburg 40 100 test1
25.04.10 newtester Bonn 40 150 sre
25.04.10 newteste 20 200
like this
Apr 27 '10 #3
semomaniz
210 Expert 100+
This is what you need to do.

Table 1 : A with primary key id
Table 2 : B with foreign key id
Table 3: C with foreign key id.

here is the sql statement
Expand|Select|Wrap|Line Numbers
  1. Select * from A 
  2.     join B on B.id = A.id 
  3.     join C on C.id = A.id
  4. where A.id = 1234  
  5.  
now using the above format you can retrieve the data from the database and then fill the dataset and then bind it to gridview

Also i would recommend to replace * with the actual field names.
Apr 27 '10 #4
Frinavale
9,735 Expert Mod 8TB
I haven't had to query a database in a long time but you could build your SQL query as such
Expand|Select|Wrap|Line Numbers
  1. SELECT table1.col1, table1.col2, table2.col1, table2.col2 
  2. FROM table1, table2 
  3. WHERE table1.somecol = 'xyz' AND table2.somecol = 'xyz'
So you would have something like:
Expand|Select|Wrap|Line Numbers
  1. SELECT statistik.date, statistik.client, address.city, statistik.container, statistik.charges
  2. FROM statistik, address
  3. WHERE statistik.password = 'thePassword' AND address.password = 'thePassword'
-Frinny
Apr 27 '10 #5
Frinavale
9,735 Expert Mod 8TB
Semomaniz's answer is probably the better solution ;)
Like I said it's been a long time since I've queried a database and I'm pretty rusty.
Apr 27 '10 #6

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

Similar topics

0
by: Faraz Ahmed | last post by:
is there a way to do inner join on null values in crystal report designer... in current scenario its not returing any rows if null values found.... as we can do that in query like x inner join...
28
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
0
by: anurag_agrawal | last post by:
Hi this i anurag, right now i am working on report genration project. I have a result set which returns me some records depend upon the EmployeeId and startdate and enddate this i passed to a...
5
by: mail | last post by:
Urgent help needed! I moved an application from ASP+ACCESS to ASP+MS SQLSERVER and I have the following problem: If the join on two tables results on duplicate colum names (which appear in...
3
by: Anila | last post by:
Hi Friends, My problem with Inner join is ... first i joined two tables and i got the result. after that iam trying to join one more table its giving syn tax error in JOIN condition. ...
2
by: icebox27 | last post by:
Need urgent help! I have 3 tables that are in Left Join ex: select * from tbl_a left outer join tbl_b on tbl_b.f1 = tbl_a.f1 and tbl_b.f2 = tbl_a.f2 left outer join tbl_c on...
2
by: cj | last post by:
My code below gives me "SQL: Column 'BTN' is not found." It will work if I use an inner join or just join but those two joins don't return all the rows. BTN has 5 rows, but arcust01 has only has...
1
by: AccessHunter | last post by:
Hi, I have a query to join two tables, Table1 - Case (Text), Division (Text) Table2 - CaseID (Text), Division Num (Number) Please help to convert (Number to text) and join the tables in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.