New command text returns data..

jamie_pattison

Well-known member
Joined
Sep 9, 2008
Messages
116
Programming Experience
Beginner
I add a new dataset to my ASP .Net project. I create a TableAdapter with one query:

Select col1, col2, col3 From MyTable

I then create a second query:

Select col1 WHERE col1=@Col1 From MyTable. I then get a warning

"the new command text returns data with schema different from the schema of the main query"

So am i doing something wrong?
How could i avoid the above message?
Why is the warning coming up?

The way i look at it is that each tableAdapter should be replicating (or close enough) each table in my database, therefore this tableadapter could have queries that return data from the same table?

I could create another TableAdapter but before i decide to do anything else, i would like to understand what and why i am receiving the above warning?

Thanks in advance

Also, before anyone says anything like search google etc, then i have and found a few people who have had a similar error but i failed to understand the reason why i cant one tableAdpater with 2 queries as above.
 
Last edited:
Each TableAdapter is associated with a DataTable. Each DataTable has a schema, i.e. a number of columns and a data type for each. Every query in the TableAdapter must produce a result set that matches that schema. Generally speaking, the SELECT clause for all queries will be the same and the WHERE clause will vary.

If you want to add a query with a different schema then you need to add a DataTable with a different schema, i.e. you need to add a TableAdapter.
 
Thanks for your explanation. Perhaps ive not fully understood this :-(

I created another TA similar to

Select col1,col2,col3
From
Table

Now i create another query under the same TA which is

Select col1, col3
From
Table

(Thats no col2). But the same warning occurs - however im under the assumption that the schema hasnt changed and all im doing is picking the columns i require?

Thanks again
 
If you create the TableAdapter with a query that selects three columns then your DataTable has three columns. You can't populate a DataTable that has three columns with a query that selects two.
 

Latest posts

Back
Top