[Mono-aspnet-list] Auto SQL generation during Update requires a valid SelectCommand

jan van der watt janvanderwatt at gmail.com
Sat Apr 25 02:27:54 EDT 2009


Thanks, I found that to work too - but there are cases when it doesn't.

I looked at the Mono (2.4) command builders and they derive from a base
class which contains a reference to the data adapter, BUT, they declare a
DUPLICATE data adapter reference in the derived class. So, when you use it
through the base class, you get this error, because the base class is using
its own reference (which is not initialised, because the initialised adapter
reference is in the derived class).

Also, the hooks to catch the Update/Insert/Delete events are hooked to the
derived class, and again, then working with the base class means that the
commands are not performed when they should be.

I "repaired" this by upgrading the base class and the derived classes in my
own namespace - however this results in becoming "platform-specific", which
is not ideal.

I also ran into other issues with using ALIASED columns and columns that may
contain NULLs, so, in the end, I gave up on the whole CommandBuilder (as
advised by many, in any case).

Still, this is a bug that should be fixed.

Of course, I could be the silly-billy that missed something - so opinions
are always welcome.


YJ Foo wrote:
> 
> MySqlDataAdapter adapter = Database.CreateDataAdapter(this.Conn, query);
> MySqlCommandBuilder cb = new MySqlCommandBuilder(adapter);
> 
> //This fixes the Mono InvalidOperation issue, but it crashes when run
> under .Net         
> //InvalidOperation: Dynamic SQL generation is not supported against
> multiple base tables.      
> adapter.UpdateCommand = cb.GetUpdateCommand();
> adapter.DeleteCommand = cb.GetDeleteCommand();
> adapter.InsertCommand = cb.GetInsertCommand();
> 
> -----------------------
> I hope this helps. I am running my application on a Windows XP system
> though, so I am unsure if my fix will be work for you.
> 

-- 
View this message in context: http://www.nabble.com/Auto-SQL-generation-during-Update-requires-a-valid-SelectCommand-tp22550410p23229052.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.



More information about the Mono-aspnet-list mailing list