Sunday, March 25, 2012

Accessing Data directly from a SqlDataSource?

First let me give you a little back ground on me. I'm very new to the ASP, ASP.NET, Visual Studio, Sql Server, Frameworks...thing. I am coming over from a PHP/MySql background of over 5 years. The change over to VBScript and VB has been to tough and I have a basic liking for the Visual Studio 2005 and the ease of putting things together. However, I have come across something that to me seems like it should be relatively simple, but haven't been able to find the documentation or samples to describe what I'm looking to do.

Rough Need:

1. Start with a form will a couple labels and a singe textbox to get the lookup date from an user.

2. Query one table/view based on the users choice of date and select only one field of returned data.(Doing this by itself is not a problem and I can display my results in a Gridview, but this is where it starts getting tricky and the gridviews won't work for me.)

3. If there is something returned, I need to start a HTML table layout or possibly some form of a Gridview(I don't see how I would use the Gridview) and start a loop, adding the first returned row from this query into the first cell.

4. Now, based on that same User Date and the returned row value from the previous query, I need to query another Table/view and return another single field, which might return 1 or multiple rows, which I need to start a loop to display unique items in cells under the first on above.

5. Based on the original User Date and each returned row from the first query, I need to query two other Table/views and get some additional information. 4-5 fields will be returned and be displayed on one row in the number of necessary columns.

6. This would finish the first row from the first query, so I would need to loop back up to see if there were any further results and continue looping until the get to the last of the results from the first query.

7. Finally, I would just need to close up the Table/gridview.

The basic results I'm looking for would be similar to the following:

Results for 10/11/2005

Field name 1Field name 2Field name 3Field name 4Field name 5

First Result from query 1
1 of 4 results from Query 2, but only 1 unique result

Info from Query 3

Info from Query 3

Info from Query 3

Info from Query 4Info from Query 4Info from Query 3Info from Query 3.

Info from Query 3

Info from Query 4
Info from Query 4Info from Query 3

Info from Query 3

Info from Query 3

Info from Query 4
Info from Query 4Info from Query 3Info from Query 3

Info from Query 3

Info from Query 4Info from Query 4

Second Result from query 1
First result from Query 2 after looping though the first query
Second result from Query 2 after looping though the first query
Info from Query 3

Info from Query 3

Info from Query 3

Info from Query 4Info from Query 4Info from Query 3Info from Query 3.

Info from Query 3

Info from Query 4
Info from Query 4Info from Query 3

Info from Query 3

Info from Query 3

Info from Query 4
Info from Query 4Info from Query 3Info from Query 3

Info from Query 3

Info from Query 4Info from Query 4

It seems me from what I have read and slowly figuring out, is that I should be able to directly access the DataSet returned by four SqlDataSources, one for each of the above querys and then just write my own VB to handle the necessary looping, table format and such. I can easily add the for SqlDataSources to the page and add a Gridview for each one and get 4 separate chunks of info, but can't see a way with GridViews to intermingle the info like displayed above.

So, if it can be done with Gridviews, then I would love to see how that is done. But, if someone could explain to me how I access the DataSets directly that I get from the 4 SqlDataSources, then that would be ok too. I have figured enough out with VB, that I can write the code to do my looping requirements, if I can just access the information I get back. Thanks for reading all the way through this long post.

Jack

First let me apologize for the mis-spellings and the two links in my sample layout. I did some copy-n-pasting, then changed the wording, but forgot to remove the link behind. I didn't see any way on this forum to be able to Edit my own post to make the necessary corrections.

Second, is this as big of a problem as it seems, since know one made any replies to it? From what little research I've done, it looks like this should be possible with nested Repeaters, but I just can't seem to figure out how to put it all together so that the second SqlDataSource can use each returned value from the results of the first SqlDataSource to get the next set of records and then again with the third and fourth SqlDataSources.

If someone could just give a very short example of a form with a single texbox and submit button, that on postback, you could manually loop through the results returned by a single field onto the page, then I think that would give me some direction here. This is one of those cases that I don't think I want to use a Control to display the returned information, I just need to know how to manually access that returned info. Thanks again.

Jack

No comments:

Post a Comment