Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2004, 04:07 PM
Authorized User
 
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default

To access a field's AllowZeroLength property by using Visual Basic, use the DAO AllowZeroLength property or the ADO Column.Properties("Set OLEDB:Allow Zero Length") property.


I really don't understand this "Note" I found in the Access help. Do I have to use this line of code even though I set my fields to allow zero length?

Is there any problem with telling my script if a text box is empty make the value " "? Will that cause problems?

 
Old March 15th, 2004, 04:30 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

No, that line refers to programmatic access to your database.

Here's how it works. Like I said, there are subtle differences in the way these properties are behaving. Null and a zero length string are not really the same:

Required No
Allow Zero Length Yes


Both will work:
Code:
oConn.Execute("INSERT INTO MyTable (MyColumn) Values('')")
oConn.Execute("INSERT INTO MyTable (MyColumn) Values(null)")
Required Yes
Allow Zero Length Yes


This will work:
Code:
oConn.Execute("INSERT INTO MyTable (MyColumn) Values('')")
but this won't:
Code:
oConn.Execute("INSERT INTO MyTable (MyColumn) Values(null)")
Required Yes
Allow Zero Length No


Now both lines will fail, because the field is required and cannot be an zero length string

Required No
Allow Zero Length No


This is the opposite of No / No. That is, this will work:
Code:
oConn.Execute("INSERT INTO MyTable (MyColumn) Values(null)")
but this won't:
Code:
oConn.Execute("INSERT INTO MyTable (MyColumn) Values('')")
Because the field is not required, you can insert null. However, you can't insert a zero length string as the field does not permit that.

Null is not considered the same as an empty string. An empty string is a string with zero length, while null is undefined.

Confusing, don't you think?

Imar

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 15th, 2004, 05:14 PM
Authorized User
 
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default

I see, I can send the (MyColumn) Values(null) instead of (MyColumn) Values('')
This is great news...I didn't really understand until you laid it out for me.

Thanks Imar
    xoxoxo

 
Old March 15th, 2004, 05:33 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome.

I don't use Access very much, so I wasn't 100% sure about all the settings and their behavior. Writing it down helped me as well. That's why I always suggest people to be supportive in forums too; it will also improve your own knowledge ;)

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 17th, 2004, 06:16 AM
Authorized User
 
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aliasp Send a message via Yahoo to aliasp
Default

Hi Freind,
to make the update code working proberly write below :

If Len(Trim(Reques.Form("attn"))) <> 0 Then

Connect.Execute = "UPDATE vendor Set" & _
 & " uiid = '" & CStr(Request.Form("uiid")) & "'," & _
 & " company = '" & CStr(Request.Form("company"))& "'," & _
 & " attn = '" & CStr(Request.Form("attn")) & "'" & _
 & " WHERE key ='" & Request("server_index") & "'"

End If

ali
 
Old March 17th, 2004, 06:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Ali,

I guess this won't work, I am afraid.

With your code, the entire UPDATE will not take place when Request.Form("attn") does not have a value.

However, it is perfectly possible that uiid and company must be updated, even when attn is empty.....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with updating the db using servlet Behl_Neha Java Databases 1 December 24th, 2007 06:08 AM
I am an idiot....DB not updating w/o Agent? Raconteur SQL Server 2000 4 April 24th, 2007 11:30 AM
Updating an Access 200 db Gandalf_the_Grey Classic ASP Basics 3 June 27th, 2006 07:09 AM
updating db with dataAdapter/dataTable problem mm1234 ADO.NET 0 November 19th, 2003 06:49 AM
Updating an Access DB stu9820 ASP.NET 1.0 and 1.1 Basics 1 September 30th, 2003 01:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.