manared
Well-known member
- Joined
- Jun 1, 2006
- Messages
- 84
- Programming Experience
- 1-3
Hi, I'm using VS 2008 and SQL. I have an application that uses several different tables. In my main table, I have the main/basic fields that I need. THere are several other tables that have detail information in them. So in my main table I create ONE entry that has an id. In the detail tables, there can be several entries for that one id. (meaning the tables can be linked to the main table through the one id.) What I want to do is create a datatable with all the information related to the one entry in the main table. My goal is to actually create a Crystal Report from this datatable. My problem right now is that i'm not quite sure how to create the SQL statement to achieve this or if I even can achieve this. Right now, I'm grabbing everything from every table (for that specific ID) and a lot of the information repeats itself for however many entries are in the detail tables. So, I know this is not the way to do it. Here's my sql string anyway for reference:
I'm sure someone will need more information, but if anyone can help me out at all, I'd really appreciate it. And let me know what information/code is needed to help me achieve my goal. Thanks!
VB.NET:
strSQL = "SELECT tblERmain.*, tblERdaily.*, tblERautoMileage.*, tblERentertainment.*, tblERmisc.*, tblERpersonal.*, tblERtravelDetail.*,
tblERledger.* FROM tblERmain INNER JOIN tblERdaily ON (tblERmain.er_id = tblERdaily.er_id) INNER JOIN tblERautoMileage ON (tblERmain.er_id = tblERautoMileage.er_id) INNER JOIN tblERentertainment ON (tblERmain.er_id =
tblERentertainment.er_id) INNER JOIN tblERmisc ON (tblERmain.er_id = tblERmisc.er_id) INNER JOIN tblERpersonal ON (tblERmain.er_id = tblERpersonal.er_id) INNER JOIN tblERtravelDetail ON (tblERmain.er_id =
tblERtravelDetail.er_id) INNER JOIN tblERledger ON (tblERmain.er_id = tblERledger.er_id) WHERE (tblERmain.er_id = '" & lblerid.Text & "')"
I'm sure someone will need more information, but if anyone can help me out at all, I'd really appreciate it. And let me know what information/code is needed to help me achieve my goal. Thanks!