accessing a table in a table adapter

pachjo

Well-known member
Joined
Dec 12, 2006
Messages
370
Programming Experience
10+
My application has numersous tableadapters with single tables in them.

At times within a function I use a select case statement to referense the required tableadapter for further processing.

I have come across a problem that occurs if the tableadapter has no tables in it with data and thus an error occurs in my code.

I suspect that to avoid this I need to check the row count and exit if 0...no rocket science needed there!

But if all I am doing is referencing the tableadapter how do I access a given table in it?

I thought I could do something like:

VB.NET:
IF taTableAdpater.Table(0).Rows.Count = 0 THEN

But have found I cannot.

As I have only created tableadapters and tables and not any datasets I am confused as to how I achieve this?

Any help please?

Thanks
 
My application has numersous tableadapters with single tables in them.
tableadapters dont contain tables

At times within a function I use a select case statement to referense the required tableadapter for further processing.
a dictionary(of whatever_you_select_on, tableadapter) would be better, but tableadapters dont descend from a common object, with is a darn nuisance.. i never found a nice way rund it other than forcing an inheritance in myself..

I have come across a problem that occurs if the tableadapter has no tables in it with data and thus an error occurs in my code.
tableadapters dont contain tables, so how can you get an error of no-data-in-table ?


But if all I am doing is referencing the tableadapter how do I access a given table in it?
tableadapters dont contain tables


As I have only created tableadapters and tables and not any datasets I am confused as to how I achieve this?
Huh? If a table was a bucket, a tableadapter would be a tap. You dont ask a bucket which tap was used to fill it, and one tap can fill many buckets, (and no tap has ever contained a bucket)

Any help please?
I'll jsut give you a brief orientation on data stuff so that you know what is called what, does what, etc.. that way youll find it much easier to separate the concepts in your mind


DataRow = a fixed width collection of typed values, a bit like an array. Each cell holds a specific bit of data (name, age, address, phone number). A drop of water.
DataTable = A variable-length collection of DataRows. A cup.
DataSet = A variable sized collection of DataTables, and relations between them. A tea-tray with lots of cups, with a ladythat can explain how the cups relate to each other.
DataReader = a device that pulls data from a (remote) data source and delivers it, serially, to a local endpoint. A pipe.
DataAdapter = a device that uses a DataReader to read data into a DataTable. A tap, that knows when to shut off after it has filled the cup.
TableAdapter = a wrapper around a DataAdapter to provide additional functionality in filling ONE PARTICULAR KIND of DataTable. Note i didnt say ONE SPECIFIC INSTANCE of a DataTable. One XXXTableAdapter can be used to fill hundreds of XXXDataTables indiscriminately. Picture a tap that can only fill a certain kind of cup, maybe one with a special lid. No other tap can fill this cup. No other cup can be filled by this tap.

There is No Link between the tap and the cup. The tap doesnt contain the cup. You put the cup under the tap and hit go. The tap is never aware of what you do with the cup afterwards; it doesnt care, it doesnt miss the cup, it doesnt yearn for it. It doesnt keep a record of which cup it filled. It doesnt need to, it is not a container of any kind. :)


If you have any further questions, dont hesitate to ask.. Hopefully the analogy clears things up a little..
 
Last edited:
Back
Top