|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Setting Null value in SQL update statementI have a sub to update a record in a sql server 2000 table.
There's a field FK, which is defined to allow nulls in the table definition, the field type is integer. How do I write the sub's definition where the parameter FK is of type integer but it's value can be NULL? UpdateDB(ByVal ID as Integer,Optional Byval FK as integer = ? ) Any help would be greatly appreciated Thanks Bob Robert Dufour wrote:
> I have a sub to update a record in a sql server 2000 table. Hey Bob,> There's a field FK, which is defined to allow nulls in the table definition, > the field type is integer. > How do I write the sub's definition where the parameter FK is of type > integer but it's value can be NULL? > > > UpdateDB(ByVal ID as Integer,Optional Byval FK as integer = ? ) > Any help would be greatly appreciated > Thanks > Bob You don't mention which mechanism you are using to update/insert your data. One way would be to set the default value of FK to some number you would never expect, eg. -9999, then if FK has this value exclude it from the insert. As the field allows NULLs you don't need to supply a value for it. I don't use Null values too often but I think you could also use DBNull.Value, but you'll have to check on that. Steve Thanks
Bob Show quoteHide quote "Jester98x" <stephen.w***@wdr.co.uk> wrote in message news:1161561462.935386.247710@k70g2000cwa.googlegroups.com... > Robert Dufour wrote: >> I have a sub to update a record in a sql server 2000 table. >> There's a field FK, which is defined to allow nulls in the table >> definition, >> the field type is integer. >> How do I write the sub's definition where the parameter FK is of type >> integer but it's value can be NULL? >> >> >> UpdateDB(ByVal ID as Integer,Optional Byval FK as integer = ? ) >> Any help would be greatly appreciated >> Thanks >> Bob > > Hey Bob, > > You don't mention which mechanism you are using to update/insert your > data. One way would be to set the default value of FK to some number > you would never expect, eg. -9999, then if FK has this value exclude it > from the insert. As the field allows NULLs you don't need to supply a > value for it. > > I don't use Null values too often but I think you could also use > DBNull.Value, but you'll have to check on that. > > Steve >
object = nothing?
Backing up with SQL MO Transparent BackGround Need a numerical evaluator validate radio button in groupbox What is the event to trap when user clicks X to close form? Managing display of a form Windows service LocalSystem account How do I get back a newly created Primary key Scaling a collection of points(lines)? |
|||||||||||||||||||||||