468,242 Members | 1,767 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

How can I default the datafield not 'null' but blank ??

In my table, the datafield set to be 'allownull', However, I want to set it
as blank but not null.
Should I put a space in the default value in sql database ?
or, During inserting record, I replace the field with ' ' when it is null ??
Thanks
Nov 21 '05 #1
7 1208
Agnes,
In my table, the datafield set to be 'allownull', However, I want to set it as blank but not null.
Should I put a space in the default value in sql database ?
or, During inserting record, I replace the field with ' ' when it is null

??

Just currious, What is your reason for that?

Cor
Nov 21 '05 #2
I got a function to fill in the object's property, E.g myObjectCompany.add1
= myReader.item("add1")
I found that [IF] add1 is null, the above statment will return "case null to
string......" (some errors)
"Cor Ligthert" <no**********@planet.nl> 在郵件
news:eP**************@TK2MSFTNGP11.phx.gbl 中撰寫...
Agnes,
In my table, the datafield set to be 'allownull', However, I want to set it
as blank but not null.
Should I put a space in the default value in sql database ?
or, During inserting record, I replace the field with ' ' when it is

null ??

Just currious, What is your reason for that?

Cor

Nov 21 '05 #3
Agnes,

So in my thougth it is the proper way to test for the VBnull.value

In a datagrid that is with the columnstyles
In a binding that is with the binding events
In a normal field just with if or case

However maybe I miss something?

Cor
Nov 21 '05 #4
On 2004-09-05, Agnes <ag***@dynamictech.com.hk> wrote:
In my table, the datafield set to be 'allownull', However, I want to set it
as blank but not null.
Should I put a space in the default value in sql database ?
or, During inserting record, I replace the field with ' ' when it is null ??
Thanks


I'd probably set the default in the db. But the last part of your
question is a bit confusing. "Inserting the record" from where? If I
didn't want a specific field to be null, then I'd also enforce that
constraint in my middle-tier data object, regardless of whether that
object was a typed dataset or my own class.

The other obvious question here is why can't you change the 'allownull'
setting in the database? If you have access to change the default
value, why not change the allownull settings as well?

Nov 21 '05 #5
The user may not input the 4lines of the company address.
However, for some object, i need to put the companyaddress to some property
myObject.add1 = table.add1, (If the table.add1 is null, this statment will
give me the error)

"David" <df*****@woofix.local.dom> 在郵件
news:slrncjmcds.86h.df*****@woofix.local.dom 中撰寫...
On 2004-09-05, Agnes <ag***@dynamictech.com.hk> wrote:
In my table, the datafield set to be 'allownull', However, I want to set it as blank but not null.
Should I put a space in the default value in sql database ?
or, During inserting record, I replace the field with ' ' when it is null ?? Thanks


I'd probably set the default in the db. But the last part of your
question is a bit confusing. "Inserting the record" from where? If I
didn't want a specific field to be null, then I'd also enforce that
constraint in my middle-tier data object, regardless of whether that
object was a typed dataset or my own class.

The other obvious question here is why can't you change the 'allownull'
setting in the database? If you have access to change the default
value, why not change the allownull settings as well?

Nov 21 '05 #6
Should I test the datafield first ??
Do you know any fast way to "convert null into "" string" , e.g cast ??
thanks

"Cor Ligthert" <no**********@planet.nl> 在郵件
news:Oh**************@TK2MSFTNGP14.phx.gbl 中撰寫...
Agnes,

So in my thougth it is the proper way to test for the VBnull.value

In a datagrid that is with the columnstyles
In a binding that is with the binding events
In a normal field just with if or case

However maybe I miss something?

Cor

Nov 21 '05 #7
Agnes,

Because you do not use the functionality of the dataset, you have as far as
I know to do everything yourself, so somewhere has to be the code

if myx IS DBNull.value then
myitem = ""
else
myItiem - myx
end if

And when writting it back again the same thing
if myItem = "" then
myx = DBnull.value
else
myx = myItem
end if

Of course can you make a function yourself from this.

I hope this helps?

Cor

"Agnes"
Should I test the datafield first ??
Do you know any fast way to "convert null into "" string" , e.g cast ??
thanks

"Cor Ligthert" <no**********@planet.nl> 在郵件
news:Oh**************@TK2MSFTNGP14.phx.gbl 中撰寫...
Agnes,

So in my thougth it is the proper way to test for the VBnull.value

In a datagrid that is with the columnstyles
In a binding that is with the binding events
In a normal field just with if or case

However maybe I miss something?

Cor


Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mark Davenport | last post: by
4 posts views Thread by Comcast News | last post: by
2 posts views Thread by mjwills | last post: by
17 posts views Thread by NuB | last post: by
9 posts views Thread by Rizwan Karedoa | last post: by
9 posts views Thread by GotDotNet? | last post: by
reply views Thread by esi | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.