if string is empty insert dbnull

G

Guest

I have a form that has several fields that need to update a db record using
SQL Data Provider. What is the best practice to insert DBNull if a text field
is empty?

I normally use if (txtbox.text == system.DBNull.Value) however, this case I
would like to set a variable to either the string or DBNull so I can simply
use it in the cmd.parameters.add functionality.

how would one declare a variable that could hold a string or dbnull.value?

Thanks
 
K

Kevin Spencer

how would one declare a variable that could hold a string or dbnull.value?

You wouldn't. What you CAN do is create a Command Parameter that has a
dbNull value.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 

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

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top