NULL Value

B

BD

Developing C# app using VS 05 to connect to remote SQL Server 05. One
form has a textbox bound to datetime column. When I delete the date
in the textbox, app locks. I was using Access 2003 to hit the
database and this did not cause a problem. Therefore, I know it can
be done but have been unable to accomplish. Have been successful in
checking for an empty string but cannot get NULL back into database
column. Any help greatly appreciated.

BD
 
N

Nicholas Paldino [.NET/C# MVP]

BD,

Have you tried using DBNull.Value for a null value? Most of the data
providers will recognize this as null.
 
B

BD

BD,

Have you tried using DBNull.Value for a null value? Most of the data
providers will recognize this as null.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Developing C# app using VS 05 to connect to remote SQL Server 05. One
form has a textbox bound to datetime column. When I delete the date
in the textbox, app locks. I was using Access 2003 to hit the
database and this did not cause a problem. Therefore, I know it can
be done but have been unable to accomplish. Have been successful in
checking for an empty string but cannot get NULL back into database
column. Any help greatly appreciated.

I have tried it, but have been unable to get it to work. My C# skills
are lacking. I have been trying to do in this in the text changed
method but I think it should be done in validating event instead. I
have turned off the validating events in the designer. I am trying to
code it with and IF ELSE statement, think it should be a Try Catch
Block instead.
 
M

Maximiliano

I have tried it, but have been unable to get it to work. My C# skills
are lacking. I have been trying to do in this in the text changed
method but I think it should be done in validating event instead. I
have turned off the validating events in the designer. I am trying to
code it with and IF ELSE statement, think it should be a Try Catch
Block instead.

Hi, if you can't get the null in c#, you may replace it on the query,
for example

SQL Server
select isnull(notes, '-')
from titles

Oracle
select nvl(notes, '-')
from titles

When you check this on the T-SQL or PL/SQL you can use it directly to
populate the field or check for a '-'.
Bye.
 

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