Abdu_Allah
asked on
DBNull.Value.ToString why it does not work?
Hi, I'm trying to use DBNull.Value.ToString in sql statement to insert nul value but it does not work, any suggestion?
ASKER
Dim fx as string
If x= 1 then
fk = DBNull.Value.ToString
else
fk = 5
end if
strSQL = "Insert into mytable(...,fk,...) values("... + fk + ")"
you "could" make your code like this:
Dim fx as string
If x= 1 then
fk = "NULL"
else
fk = 5
end if
strSQL = "Insert into mytable(...,fk,...) values("... + fk + ")"
however, I repeat, using the db Command + Parameter objects would be better...
ASKER
Isn't it possible to do that in the way I put?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you used a Command object with Parameters, then you can assign the DBNull.Value as such to the parameter, then it will work.
please show your code.