Is this the correct way to use tableadapters

pachjo

Well-known member
Joined
Dec 12, 2006
Messages
370
Programming Experience
10+
I will try to keep this simple hoping I explain myself correctly:eek:

I have a database which among others has two tables I am trying to use correctly.

Transactions

TransactionID
TransactionDate
DescriptionID (foreign key - TransactionDescriptions)
TransactionAmount

TransactionDescriptions

DescriptionID
Description

In my dataset I originally had these set as they are with all the designer generated queries, select, insert etc.

Now I found that when diplaying the transactions in my listview I need to see the actual description not the description ID.

So I amended the .Fill query to include an inner join between the two tables so that in the dataset designer Transacations now looks like this:

Transactions

TransactionID
TransactionDate
DescriptionID (foreign key - TransactionDescriptions)
TransactionAmount
Description

Now the .Fill will still do what I need to allow me to continue as I have up until now.

But what has happened is that code in ohter parts of my app that calls
Me.TransactionsTableAdapter.Update now errors saying that .Update does not exist.

I realise this is due to the joining of two tables and that I need to create the update, well the insert command myself.

However.......I cannot see where it is that I do this!

Any advice gratefully received

Thanks
 
Last edited:
OK the way I got around this was to start again and create a standard .Fill method which in turn allowed all the insert, update etc queries to be generated.

I then created another query to be used with the listview and call that when refreshing the listview control and it works OK.

However I don't fully understand tableadapters and bindingsources.

So I am going to open a new thread so as not to mix it up with this one.
 
For things like this, we normally want to show data in a grid..

In this case I would:

Fill Transactions
Fill TransactionDescriptions
Have a DataGridView show the contents of Transactions
Use a DataGridViewComboBoxColumn to a)decode the id into a description and b) provide some ability to edit the ID by choosing another description


There isnt really anything to do with tableadapters here, but suffice to say that one golden rule is well observed:

It is rare that you will write a JOIN query in a tableadapter select statement (to the effect that I have been doing data access this way for a year now, and I have yet to write one with a JOIN)
 
Back
Top