Why is DbCommandBuilder generating DEFAULT VALUES on the end of some INSERT statements?

R

Reggie Burnett

Our CommandBuilder class derives from DbCommandBuilder and everything works
except for when there are not column values given in an insert and
DbCommandBuilder wants to generate default values. In that case, it appends
"DEFAULT VALUES" onto the end of the insert command. Why on earth is this
done? The bigger question is why oh why aren't the GetUpdateCommand,
GetDeleteCommand, and GetInsertCommand declared as virtual so we can
override them and still have db neutral code?

Reggie
MySql, Inc.
 
C

Cor Ligthert [MVP]

Reggie,

The commandbuilder is a solution for probaby 80% used simple datahandling
(80% in creating programs not in actual use there it will be probably less
than 20%). (Updating simple reference tables).

Don't expect it to be a kind of one time solution for every possible
problem.

Although I do not agree the complete article from Bill because I find the
commandbuilder in the situations I describe above a great and simple tool,
do I agree the part where he is writing about complexer situations.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/commandbuilder.asp


Cor
 
R

Reggie Burnett

Thanks for your response. However, understanding the CommandBuilder is not
my problem. Basically, Microsoft is assuming that all datasources will
understand the "DEFAULT VALUES" SQL and so they have therefore hard coded
this into their DbCommandBuilder class (which we are supposed to derive
from).

I'm assuming that Microsoft wants people to be able to write db neutral
code. That was the whole idea behind the Dbxxxx base classes. However, by
not virtualizing some of the important methods on DbCommandBuilder, it's
difficult to write efficient db neutral code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top