I'm kind of new to C# and am trying out the convenient looking adaper-dataset combo with local database. while I was amazed at how easy and useful it was I stumbled upon an issue:
Whenever I try to fill the Item table with the adapter I get Invalid object name SQLexception, I use the same Dataset for all my tables, dsOns.Users / dsOns.Items. The problem is, the users adapter does recognize and successfully works with Users database(dbo.Users) while the items adapter cannot find the table(dbo.Item).
Heres some sniplets:
UsersTableAdapter uAdapter = new UsersTableAdapter();
ItemTableAdapter iAdapter = new ItemTableAdapter();
Users select:
SELECT Id, name, password, sold, isLogged, lastLog FROM dbo.Users
Item select:
SELECT Id, name, sale_price, min_price, cog FROM dbo.Item
Both use the same connection string:
Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\ons_data.mdf;Integrated Security=True;Connect Timeout=30
Also note that in Dataset designer, the adapter works fine, it selects successfully. The error only occurs in code.
Image of the schema:

What could possibly cause this?
Okay that was weird, I solved it by simply changing the view of the database explorer, to find that the app uses two databases, in UI(dataset designer) it uses my original db, while in code it uses the same db(but outdated since I changed it via dataset designer) that was copied to debug folder, hence containing only Users table alone and resulting in the error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With