|
I am trying to write a DDEX provider and am having trouble figuring out an error condition. The connection shows up in the Server Explorer along with the appropriate nodes (tables, views, etc.). The tables expand and show their columns, column type information shows up in the properties window. But when I drop a table onto a dataset, it gives the following error:
Could not retrieve schema information for table or view test.
I get the same error if I go through the menu Data\Add New Data Source...
The error seems to be the generic top level "something failed" error because it appears in response to any number of things I manage to implement incorrectly. Each time I encountered it, though, there was some kind of exception information that allowed me to correct what it did not like.
However, now I am not getting any exception (handled or unhandled) as far as I can tell. Just the error message. I set options in the debugger to stop on every possible exception even if it occurred on the PC in the next room (well... you get the idea). The underlying VSDesigner code is successfully retrieving schema information from the DbConnection object and the DbDataReader and is creating INSERT, DELETE, and UPDATE commands for the table; I can see all the appropriate SQL statements, parameters, etc. being created inside my DbCommandBuilder, DbParameter, and other objects. The last thing that happens is that it creates the DELETE command (completely as far as I can tell) and then it makes no more calls into my code after defining the last parameter. It just gives that error message.
So I have obviously done something wrong. But it's unclear where to look next.
Any suggestions about what to look at or how to figure out what VisualStudio is unhappy about? I've viewed, reviewed, and re-reviewed the previous set of posts on DDEX issues and didn't come up with anything that helped.
Thanks in advance, Mark Wilkins | | Mark Wilkins Friday, November 04, 2005 12:12 AM | Generating a typed dataset hits just about *everything* in your provider. Search this forum for DDEX or SQLite and you'll see my progress through making the ADO.NET 2.0 Data Provider for SQLite. Better yet, download the source and see how I ended up. It may in turn help you along with your provider. Robert Simpson http://sourceforge.net/projects/sqlite-dotnet2 | | Robert Simpson Friday, November 04, 2005 10:52 PM | Generating a typed dataset hits just about *everything* in your provider. Search this forum for DDEX or SQLite and you'll see my progress through making the ADO.NET 2.0 Data Provider for SQLite. Better yet, download the source and see how I ended up. It may in turn help you along with your provider. Robert Simpson http://sourceforge.net/projects/sqlite-dotnet2 | | Robert Simpson Friday, November 04, 2005 10:52 PM | Hi Robert,
Thanks for the response. I have read through your original posts about the DDEX development. I chuckled at the descriptions of how the development was a lot of "try everything until something works". That's exactly how I have been doing it too. It's a somewhat painful process; hopefully the documentation will be improved at some point.
I may take a look at your code to see if anything rings a bell. It will at least be a change of scenery from those 4 samples that ship with the SDK.
Thanks, Mark | | Mark Wilkins Saturday, November 05, 2005 12:40 AM | Dear Mark,
the error you see is displayed when a call to IDbDataAdapter.FillSchema() does not return a DataSet or the DataSet returned does not contain any tables. The select command used here is
SELECT <columns selected in the wizard> FROM <table selected in the wizard>
in your case it is probably "SELECT * FROM test" or something along these lines.
Without this information we cannot really create a typed table inside a typed DataSet.
I hope this information proves helpful Karol Zadora, Visual Studio Development Team | | Karol Zadora - MSFT Tuesday, November 08, 2005 10:01 PM | Hi Karol,
Thank you. That gives me some more things to look at, but I am still a bit puzzled. If I simply write some standalone code that calls FillSchema on my data adapter class, it does return the DataTable with the column information in it. It ends up calling my DbDataReader.GetSchemaTable() as I would expect.
I have not implemented the FillSchema methods on my DbDataAdapter; it just inherits them from the base class. However, for test purposes, I added those methods (3 different overloads) and simply called the base class implementation. Those methods never get called, though. My DbProviderFactory.CreateDataAdapter() method is called, and I can see that it gets populated with the appropriate SELECT command, but the FillSchema() method is simply never called.
Do you have any ideas on what might prevent the underlying code from even attempting to call FillSchema? As I mentioned in the original post, there are no exceptions being thrown, so I am a bit at a loss to determine what I have done wrong. But I haven't given you much to work with either.
Thanks, Mark Wilkins | | Mark Wilkins Thursday, November 10, 2005 6:12 PM | Did you read one of my other posts about typed datasets? Here's a copy: Dropping a table onto a dataset designer hits just about every single DbXXX function there is (with the exception of DbTransaction).
Here's some general observations about what was impacted while trying to make it work: - Your DbProviderFactory (of course)
- Your custom DataSourceInformation class in your designer
- It gets DefaultCatalog, DefaultSchema, CatalogSupported, SchemaSupported, and I think gets CatalogSupportedInDml and SchemaSupportedInDml -- plus a few other properties.
- Your DbConnection->GetSchema()
- It retrieves DataTypes, Tables, Columns, Views, DataSourceInformation and possibly others if they exist, including ReservedWords
- DataObjectIdentifierResolver (designer), QuickExpandIdentifier() and QuickContractIdentifier(). Sometimes the input parameters had DbNull instead of just null in them, which I replaced with regular nulls, but I was just shooting in the dark.
- Creates a new connection, and uses your DbCommandBuilder, DbDataAdapter, DbCommand, DbDataReader, DbParameterCollection and DbParameter classes to build some schema queries
- Uses DbDataReader.GetSchemaTable()
- Uses the catalog, schema and base table information from GetSchemaTable()
- Your DbConnection.Database and DbConnection.DataSource properties
I highly recommend you create at least a DataObjectIdentifierResolver and a DataSourceInformation implementation in your designer code so you can trace through the calls. You'll also have to set breakpoints in your Connection's GetSchema() function(s) so you can see what parameters are being passed and what you are returning back. It may not throw an exception, but that doesn't mean garbage hasn't been passed.
Your DbConnection->GetSchema()'s "DataSourceInformation" return data is also important.
Robert
| | Robert Simpson Thursday, November 10, 2005 6:34 PM | Hi Robert,
I have read all of your original posts including that one. And I used your suggestion of dropping a table onto the dataset designer. That was a very useful tip. I subsequently stepped through every single call it made into both the provider and the designer. Everything looks correct to me - but I am likely overlooking an error (that seems self-evident). I've stepped through all the GetSchema calls and compared the results to what is produced by the equivalent SqlClient connection object. In fact, I dumped those tables to an XML file and read the schema in as the basis of my schema tables just to make sure I wasn't missing a column.
I also have DataObjectIdentifierResolver and DataSourceInformation classes implemented. I'll check the property values specified in my DataSourceInformation constructor. Maybe I have chosen a bad value.
Thanks, Mark Wilkins | | Mark Wilkins Thursday, November 10, 2005 6:53 PM | It could be a problem in the XML file definitions as well. I wouldn't discount that.
Robert
| | Robert Simpson Thursday, November 10, 2005 8:19 PM | Hi Robert!
Try to implement ICloneable interface in your DbCommand class.
This solve my problem. Good luck!
Egon | | Egon Rosa Pereira Sunday, June 04, 2006 2:02 AM | Egon,
Thank you, thank you, thank you soooo much! That helped sole the problem I've been having with my DDEX provider the last six months.. I've gotten "Object reference not set to an instance of an object" errors whenever I try to create a DataSource from the wizard, but now it works perfectly! Can someone please point me to some place where it says that DbCommand-derived classes should implement ICloneable?? If not, maybe there should be such a place (like, say in the DDEX documentation...?)
/Anders
| | Anders Ljusberg Monday, June 26, 2006 3:09 PM |
|