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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you allow a zero-length string?

Status
Not open for further replies.

crashc123

Technical User
Oct 3, 2001
80
0
0
US
I want to be able to allow the user to leave certain input fields blank but i get an error message when I do this.

"Field 'Projects.Aircraft' cannot be a zero-length string."
The database is set to allow empty fields so how can I fix the asp to allow it?

Thanks in advance for your help.

 
If you have already set the table properties of that field to allow zero length, it shouldn't be a problem.

May be try putting this to your SQL statement to default any blank field to empty string.

INSERT (or UPDATE) tabelnemat (field1, field2)VALUES ('YourName','')


Hope it helps

Regards
 
how would I do it with this?

strSQL = "UPDATE Projects SET " _
& "JobNo='"& Request.Form("JobNo")&"',"_
& "Title='"& Request.Form("Title")&"',"_
& "Description='"& Request.Form("Description")&"',"_
& "Aircraft='"& Request.Form("Aircraft")&"',"_
& "JobType='"& Request.Form("JobType")&"',"_
& "Engineer='"& Request.Form("Engineer")&"',"_
& "Focal='"& Request.Form("Focal")&"',"_
& "DER='"& Request.Form("DER")&"'"_
& "WHERE (ID="& iRecordId &")"

Okay I think that I have set the database table to allow empty fields. When I put some trial recordsets in I left some of the fields blank and since this didn't create a problem I assume it's okay. Also to display my table via asp I put " " so there would be an empty cell in the table.
 
What database are you using? Are you going through ADO?

Where I work we have SQL Server 2000 and are using ADO within VB6 and VBA apps. If I wanted to do an update to the database like that, I would have the DBA create a stored procedure for me that would accept each parameter you have there in the update. Then I would create an ADO.Command object that would call the <b><i>compiled</i></b> stored procedure, passing it the parameters. The database would make its highly optimized call and probably offer a return code and a recordset containing the updated record.

The empty field issue you're having... You can set a field in a table to be able to accept NULL values. If you turn this on, then that field will not give you problems. If you can't do that then -Chris Didion
Matrix Automation, MCP
 
Try this :


my_thing = Request.Form(&quot;my_thing&quot;)

rs.insert
If my_thing = &quot;&quot; Then
rs(&quot;mything&quot;) = NULL
Else
rs(&quot;mything&quot;) = my_thing
End If
rs.update
rs.movelast Regards

Big Dave


** If I am wrong I am sorry, but i'm only trying to help!! **

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top