SqlCommandBuilder and null fields

  • Thread starter Thread starter Darren
  • Start date Start date
D

Darren

I'm using a SqlCommandBuilder to construct an insert command using the
GetInsertCommand().

The command builder doesn't change the parameter's IsNullable value based on
the schema which allows some columns to be null.

The result is I cannot insert a new record with parameter values set to
null using the command that was built by GetInsertCommand
 
Darren, we've talked about the CommandBuilder for quite some time.
Generally, it's not recommended nor endorsed by most pros who sooner or
later come to the conclusion that it's not much good for anything but (very)
simple operations. Since most developers use stored procedures to process
CRUD operations, generation of client-side code to do so simply isn't
necessary. Here is a link to an article on the subject
http://www.databasejournal.com/feat...Operations-Using-Stored-Procedures-Part-1.htm.
I've also written a few myself including
http://www.sqlmag.com/Article/ArticleID/97182/sql_server_97182.html as well
as a number of chapters in my book that explain how this is done.

hth

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com http://betav.com/blog/billva
____________________________________________________________________________________________
 
Bill,

For a lot of people the commandbuilder is really a solution.

The popularity of Linq to SQL (Datacontext) is probably as well becaused of
that. A simple submit from the selected values does with that the job, while
as far as I remember me this, it is the same with a recordset.

Although I know how to make an Insert and an Update I always find it a hell
to keep the values and the datanames in line (or not to forget one).

As last argument in this, SQL is not the most easiest code as it is grounded
on plain(American) English and probably because of that probably easy for
Americans but sometimes difficult for those who don't understand the
finesses from that dialect.

Maybe something to think about before you abandon the commandbuilder

Just my thougt reading your message

Cor
 
I'm firmly planted in the dynamic query camp so I tend to avoid stored
procedures like the plague.

IMHO if it's in the framework then it should work. It's a two line
correction.

I can work around the issue but I should not need to.
 
Back
Top