472,992 Members | 3,586 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

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 1344
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark Davenport | last post by:
Hi, Here's my question: How do I pass a NULL value in a variable to a MySQL DB? Here's an overview of my problem: I have a PHP page that processes code, then inserts the code into a database....
1
by: Scott | last post by:
In the result of a SELECT statement, how can you change cell values from NULL to BLANK? The following does NOT do it: SET fieldname = ' ' WHERE fieldname IS NULL Also, for colums with a DATE...
4
by: Comcast News | last post by:
I have some DDL from DB2/mainframe and it does not list the default value. Example: create table foo ( col1 char(2) not null with default ); Question: So what value does DB2 default in...
2
by: mjwills | last post by:
All, I am using VB.NET 1.0 / 2002. I am having trouble setting a column default to "" (note that "" is not the same as Null / DBNull / Nothing) in a typed dataset (to reflect the same database...
17
by: NuB | last post by:
I have a sql query that is doing an update of records, how can I add NULL to the field in the database if the field on my screen is blank? example: I have 5 textboxes, and a user can leave some...
9
by: Rizwan Karedoa | last post by:
Hi experts, I am developing an application, I am using vb 2005 and access. I have many date fields, When I am saving through Query for default date I save 1/1/1500 so when i find that date agian I...
9
by: GotDotNet? | last post by:
I have a dataset and I have to loop through it and some of the values for an insertition into the db. Some of the fields are integers and booleans but contain a NULL in the field. how can I...
0
by: hanusoft | last post by:
This is an example of editing in DataGrid and Default Paging http://www.hanusoftware.com Html Design Code : - <asp:DataGrid id="DataGrid1" DataKeyField="id" runat="server" Height="224px"...
0
by: esi | last post by:
New to ASP.NET so any help you can offer would be great! I have been searching the web all day to try and figure out how I can add a default value to a field on a DetailsView control. I did...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.