Problem with TableAdapters

roshanstevv

Member
Joined
Feb 8, 2007
Messages
12
Programming Experience
1-3
I am using Table Adapters for retrieving the data..
I have wirtten a Query for retriving the data from the database by right clicking the table adapter and clicking on configure and choosing a correct stored procedure for the operation..( hera iam retriveing values from 4 Feilds) say name mainqueryRetrieve

now I need to retreive data by checking some conditon. I done this by right Clicking the table adapter and clicking ton add query and selecting the correct stored procedure( here iam retrieving values from 10 Feilds since there is inner joins and other tables values) say name otherQueryRetrieve

I receieve a message as shown
"The new command text return data with schema diferent from the schema of the main query.Check the quey command text if ti si not desired"
when i call the newly created method otherQueryRetrieve its don call this..it calls mainqueryRetrieve
is there any method to overcome this?
thanks in advance
 
Right.. A TableAdapter is a device for filling a DataTable, from a data source.

The original query is used to automatically define the structure of the table. THis is so you dont have to laboriously create a 200 column datatable to match a schema that is programmatically accessible (its the wizard trying to be helpful)

If you then go and add another query to the same tableadapter that returns a different bunch of columns.. where are they going to go?


What you need to do is either, make another tableadapter and datatable entirely, or use a datatable sufficiently complex that it can hold the content of either query

Your main query returns 4 columns, lets assume these are A B C D
The other query returns 10 columns.. Lets assume these are C D E F G H I J K L
OtherQuery WILL WORK, BUT... The only columns that are known to be able to hold the results are the overlap: C and D.. The contents of the other 8 columns will be discarded

With me so far?

Either make a DataTable that has A B C D E F G H I J K L
Main will fill the bold columns, other will fill the underlined columns

Or make two datatables
 
Its because you're trying to view 6 fields in your second query that don't exist in your created dataTable.

If it's a requirement the easiest way of doing this is to create 1 dataTable for your 1st query and another dataTable for your 2nd query.


edit: No response when I replied....basically Cjard got there before me! :D ... go with what he said, he tends to be right (well 99% of the time ;) )
 
Back
Top