Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
May 11, 2000

Sending Null Values to a Required Field

Question:

When I try to send some information to an access database through ASP, I get the following error:

[Microsoft][ODBC Microsoft Access 97 Driver] Field 'tablename.class'
can't be a zero-length string.

This is the code from my page:

Set conn = Server.CreateObject("ADODB.Connection") 
data_source = "DBQ=" & Server.MapPath("filename.mdb") 
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & data_source

Define strSQL

conn.Execute strSQL
conn.Close 
Set conn = Nothing 

Can you tell me what I'm doing wrong?

Answer:

You are getting this error because you are trying to create a record in a table where one or more of the fields (in your case the field 'Class') is a required field. That is, within Access, in the Table Design window, the 'Allow Zero Length' property for the field has been set to 'No.'

There are two ways to solve this problem. First, think about whether you would like to have a record in which the field 'Class' will be empty, or null. If that is OK, open the Access Database, and go to the Table in Design mode. Then, navigate to the field and, down in the bottom, choose 'Yes' for 'Allow Zero Length'. Save your table and your existing code will start working.

If you think the field Class should never be empty or null, then adjust your interface code to make sure you or your user always fills in a valid value before updating the data.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date