hi

i'm working with a database application and i want to check if there is a null value in a specific column but it works only when its not null but if its null it throws an exception automatically

i tried to change the nullvalue property of this column but i'm not able it shows a message that its not a valid property

i tried to change the source code in the code editer but it changes back automatically

is there a way that i can work around this?

It would help if we knew what type of database you are using. In MS SQL Server, there is a function (COALESCE) that can be used to substitute other values if a database field contains NULL. For example, the following query

select last_name, middle_name, first_name from myTable

would return NULL if there was no entry for middle_name, however

select last_name, coalesce(middle_name,"none"), first_name from myTable

would return "none" as the value for middle_name instead of NULL

There is a similar function, NZ, in MS Access.

thanks for your answer i didn't thought about this
yes i'm using ms sql server and i knew of this function i forgot it

but there is also a way to work around the visual studio it self on this problem?

As far as I know, not one that isn't messy (requires writing interface code). You are much better off letting SQL server do the substitution for you.

As far as I know, not one that isn't messy (requires writing interface code). You are much better off letting SQL server do the substitution for you.

i used the following code

if tablename(0).iscolumnnamenull =true then
=============
elseif tablename(0).iscolumnnamenull =false

=========
end if

it worked fine

thank you all for your effort

You can do this in vb

If IsDBNull(value) then
 'Value is null, place code to handle here.
End if
commented: OK. Not so messy after all. +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.