locked
The schema returned by the new query differs from the base query RRS feed

  • Question

  • hello all , 

    I have created a data-grid box from access table containing columns as below :

    SELECT ID, [Size in mg], [Die head number], [Inspection Date], [Next Calibration Date], [Die size in microns], [Condition of DIE-1], [Condition of DIE-2], [Condition of DIE-3], [Condition of DIE-4], [Condition of DIE-5], [Condition of DIE-6], [Condition of DIE-7], Observations, Inspector FROM MSdies

    But when i tried to create a query as below the error message is coming saying:

    The schema returned by the new query differs from the base query

    SELECT        ID, [Size in mg], [Die head number], [Inspection Date], [Next Calibration Date], [Die size in microns]
    FROM            MSdies
    WHERE        ([Die head number] < NOW())
    Please guide me how to solve this

    Tuesday, July 21, 2020 7:56 AM

Answers

  • Sounds like you are working with at least one TableAdapter and looks like you are using the bottom query rather than the top query which was auto-generated. This will work for a read-only view but not if editing for instance is desired.

    You must return all column specified in the base query.

    Example

    FillData below was auto-generated and has 

    SELECT 
    	CustomerIdentifier, 
    	CompanyName, 
    	ContactId, 
    	Address, 
    	City, 
    	Region, 
    	PostalCode, 
    	CountryIdentifier, 
    	Phone, 
    	Fax, 
    	ContactTypeIdentifier, 
    	ModifiedDate 
    FROM Customers

    If we edit something all works. while in FillBySmall which has a sub-set of columns when edit/saving an exception is thrown because all columns were not specified.

    SELECT 
    	CustomerIdentifier, 
    	CompanyName, 
    	ContactId, 
    	Phone, 
    	Fax, 
    	ContactTypeIdentifier
    FROM Customers

    While the middle works because we specified all columns

    SELECT 
    	CustomerIdentifier, 
    	CompanyName, 
    	ContactId, 
    	Address, 
    	City, 
    	Region, 
    	PostalCode, 
    	CountryIdentifier, 
    	Phone, 
    	Fax, 
    	ContactTypeIdentifier, 
    	ModifiedDate 
    FROM 
    	Customers
    WHERE
    	(CustomerIdentifier = ?)


    Solution is to always specify all columns or abandon working with TableAdapters 

    Important stay away from using data wizards which generate code that use TableAdapter unless you plan on learning the disadvantages and quirks, otherwise you will struggle continuously.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, July 21, 2020 11:34 AM