CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 How to prevent inserting NULL for a text field

Print topic Send  topic

Author Message
itw_peter

Posts: 6
Posted: 05/28/2009, 10:24 AM

Hi,

If a text field is empty, CC ASP code will write a NULL into the database.
I need it to write an empty string instead of a NULL into the database.
How can I achieve that?
Thank you in advance.

Regards,
Peter
View profile  Send private message
Edd


Posts: 547
Posted: 05/28/2009, 4:13 PM

Use he custom insert (SQL) or stored procedures.

I have one supplier who does this all the time and it really bites.

Cheers Edd
_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message
davidwoo

Posts: 53
Posted: 05/28/2009, 8:31 PM

I think it's depend on yr database setup, I am using ASP/MySQL 5, the default value for the text set to empty string, numeric set to 0...etc.

BR
View profile  Send private message
Edd


Posts: 547
Posted: 05/28/2009, 9:07 PM

My experience is MSSQL / Sybase and MSAccess - look at the code in the Common class but I think you will find that it converts to NULLs if the data field is empty.

Cheers - Edd
_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message
peterr


Posts: 5971
Posted: 05/28/2009, 11:42 PM

Hi,

This doesn't depend on database if you use the first solution provided by Edd - the "If parameter is empty" option in Custom Insert.
This is standard CCS feature therefore should work the same with all databases.

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
itw_peter

Posts: 6
Posted: 10/20/2009, 10:34 AM

Hi,

I tried using this piece of code in the events page:
If len(form1.account_sub_no.Value) = 0 then
form1.account_sub_no.Value = " "
End If
It still inserts null.

But if I use a space like this: form1.account_sub_no.Value = " " , then it works.

Is there a way to insert empty string rather than a space?

Any help will be appreciated.
Thank you in advance.

Cheers
Peter
View profile  Send private message
musarrataziz

Posts: 2
Posted: 10/21/2009, 4:56 AM

Function Customer_DataSource_BeforeExecuteInsert



if len(Customer.name.Value)<1 then

Customer.DataSource.CmdExecution=false


end if


End Function


'' Hope you can Understand this..
_________________
Musarrat Aziz
Software engineer
View profile  Send private message
itw_peter

Posts: 6
Posted: 10/21/2009, 9:40 AM

Musarrat,

Thanks for your reply, however, that does not work for me.
Your solution will simply not insert the whole record.
What i need is that it inserts all the fields, with that particular field set to empty string.

Thanks.
View profile  Send private message
ReneS

Posts: 225
Posted: 10/22/2009, 2:37 AM

Hi,

Got this from: http://forums.devshed.com/net-development-87/how-to-ins...rce-494170.html

So maybe this works: When designing your tables, SQL Server allows you to replace nulls with a default value on insert. Make your fields non-null in your database, and give them an empty string for a default value.

Hope it helps.

Rene
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.