Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"zero length string" error 2

Status
Not open for further replies.

leadman

Programmer
Jun 11, 2001
177
US
here's the problem:
I have a form field named email.
On submit it goes to a processing page that has the following code:
<cfparam name=&quot;email&quot; default=&quot;off&quot;>
<cfquery name=&quot;&quot;
datasource=&quot;ccdb&quot;
dbtype=&quot;ODBC&quot;>
insert into
questionaire (email)
values ('#email#')
</cfquery>

If nothing is put into the email field
the follwing error occurrs:

ODBC Error Code = S1000 (General error)


[Microsoft][ODBC Microsoft Access Driver] Field 'questionaire.email' cannot be a zero-length string.

I thought the cfparam tag should give the email variable a default value of &quot;off&quot; that would then be inserted into the database?



 
Your field must be specified in Access as 'Allow Zero Length?' = Yes

Although CF is not expecting a length access still is.

 
thank you thank you!! I made the change and now there is no more &quot;zero length string error&quot;......Um, could you tell me why, instead of putting the form info into the database (ccdb.mdb) - another file was created in the database folder on the site called ccdb.ldb? I cant even open that extension!
 
I have this happen also. I asked my web host about this and they feel it may be due to FP extensions being installed. My opinion is CF stores somewhat of a temporary file with the same name and different extension.

If you change the name of you DB (why?, just to do it) you will see this other either go away until the DB is used or it will change also.
 
The file with the extension .ldbis a lock file. This file is created when a (access) database is opened, and keeps track of things if the table record can be modified by another user at the same time or not, etc.
To react on the <cfparam name=&quot;email&quot; default=&quot;off&quot;> this will insert 'off' in the variable 'email' only when the variable does not excist. When you send the form the variable contains an empty string and the value 'off' is replaced with the empty string. You need to do something like
<cfif IsDefined(&quot;form.email&quot;) AND form.email IS &quot;&quot;>
<cfset email = &quot;off&quot;>
</cfif>
 
yes - i see. That makes sense. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top