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

Query a dataset for binding (ADO.NET)

22
Hi all and thanks for looking.

I need to make the move from ASP to ASP.NET, and as my sister has aked me to knock up a website for her, I thought this could be a nice starter project to help me learn.

The site displays thumnails of images she will upload. Each file needs some information stored in a database about it. In classic asp I would have created a list of images and realated info within a database and driven the site from this. However i thought it would be a nice idea to use the filesystem to list the images.

My plan was to create a DataSet with 2 DataTables. One DataTable full of filenames found in a folder and the other DataTable full of file info loaded from the database. Then I would create a relationship between these tables and (this is where it gets cloudy) bind this to some DataList or something?

So far I have got my dataset with both tables filled with the information as sugested, and created a relationship between them.
Now I'm stuck!!!

How can I bind this information? I still have 2 DataTables! Is it now possible to query this information to put it into a single bindable table or something, or is my whole approach not going to work?

thanks for your time!
Dec 29 '08 #1
8 3409
Frinavale
9,735 Expert Mod 8TB
@TimVtoo
This is exactly what you're going to have to do.

You need to write SQL that queries from both tables to create your "Bindable" table.

Then how you use the table is up to you...you could bind it to a GridView or just use a Repeater to display the images. There's a lot of options at that point.

To get you pointed in the right direction, check out the article on how to use a database in your program.

Also, the MSDN Library is a very powerful resource to use while developing .NET applications. There you can find information on GridViews, DataSets, Repeaters, and much more.

Cheers!

-Frinny
Dec 30 '08 #2
TimVtoo
22
Hi Frinny, thanks for your reply, but i think you may have slightly misunderstood me.

Both of the DataTables I have are ADO.NET tables in the ASP.net application itself as one of the tables is derived from the filesystem. So if I am to create a query to bring this data together, it needs to be done in the application and not a database using ado.net.
My intension here is really to get my head around what I can and cant do with .net AND ADO.net. I have a pretty good understanding of databases, but its the .net i'm new to !
Dec 30 '08 #3
Frinavale
9,735 Expert Mod 8TB
Check out the DataView object and the DataViewManager object.

I think you're going to have to create DataViews for your tables and use the DataViewManager to join them together to be used as a data source for whatever control you're binding the data to.

There might be an easier way to do this....and I'm wondering if LINQ could help you in anyway...but give this a try and if it's not to your liking maybe we can find another solution :)

-Frinny
Dec 30 '08 #4
TimVtoo
22
Thanks Frinny, but as far as I can tell, a data view manager is for hadling Sorting and Filtering for multiple DataTables but they still dont help with combining tables as a join in a database query would. :(

Just to clarify what I'm trying to achieve here.
SIMPLIFIED:
I have an ADO DataTable that contains a list of Image Files found in a specific folder.
I have another ADO DataTable that contains a list of Alias's for these Images.

I am currently diplaying a thumbnail of each image with it's image name underneath it. What i would like to do is display the Alias (from the other table) instead of it's filename under each thumbnail.

Any more suggestions would be welcome!

Thanks

Tim
Dec 30 '08 #5
Curtis Rutland
3,256 Expert 2GB
OK, so just to be sure, it isn't possible to do this at the query level? Write one query that handles your join and returns one table?

If not, you might just have to create your own third DataTable with the columns you need, and loop through and fill in the cells manually.

Also, this might be worth reading:
HOW TO: Implement a Custom DataView Class in Visual Basic .NET
Jan 2 '09 #6
AricC
1,892 Expert 1GB
I'm a bit confused is the data for the folder coming from a DB? If so do what insertAlias said and join the two tables you should have a column in your DB that links the two or are they coming from the file system?
Jan 3 '09 #7
TimVtoo
22
@insertAlias
You are right in saying this can't be done at the query level.

The file/folder info is being done using the DirectoryInfo & FileInfo methods and filling an ado datatable with what it finds.

I took this approach so that it will only ever list files that actually exist AND because I thought it would be a good learning execise.

If nothing else I may have learned that this is not a good approach :).



I'll have a look at the link you posted insertAlias.

Thanks for getting back guys, thought this had dies a death!
Jan 3 '09 #8
TimVtoo
22
OK, it is becoming apparent that relating ado datatable is not going to work for me here.

It has just occured to me (duh) that rather than putting the filnames I find into an ado table I can just use them in a string to build an SQL statement to retreive my alias's right?

But, as I said, i was doing the related ado table thing as a learning excercise, so could someone please give me a good (simple) example of where Relating ADO DataTables is usefull ??

Thanks again for your time!

Tim
Jan 3 '09 #9

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

Similar topics

9
by: M O J O | last post by:
Hi, (I'm new to XML) I can export data from Access as an XML file (with schema integrated in the XML file). I can read it into a DotNet DataSet, but the schema is not correct that is - I do...
5
by: JFB | last post by:
Hi Folks, I have two tables in one dataset customers and orders. If I select a customer form a combo box, how can I set the where statement for the orders table? I want to display all the orders...
10
by: Fares Eidi | last post by:
I am a VB6 intermediate programmer just starting out using VB.net and would like to ask what I'd be missing out on if I just use time saving techniques like data binding, data adapter wizards etc...
10
by: jaYPee | last post by:
as of now i am using a stored procedure from my sql server 2000 to insert record from another table. what i need now is on how can i insert record by not using the stored procedure and insert it...
16
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill...
1
by: Abubakar | last post by:
Hi, Lets say I have 3 rows in a dataset bound to a datatgrid. Now I want to add a new blank row before the second row in the dataset. How am I going to do that? I think there was an insertat...
13
by: Maxwell2006 | last post by:
Hi, We are having a debate over using DataSet as return value type for web services. The problem is that we don't know whether Java applications can use DataSet
2
by: forforumsid | last post by:
Hi all I have a Dataset name: dsMain I popullate with all the data from the database on form load event I have a requirement to filter data as per users requirement on a button click event ...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, I created a simple dll in VB2005 to use ADO.Net -- oleDBDataAdapter to write data to an Excel file. The code (below) works fine from an Excel file (invoke the dll from Excel to write to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.