Sending Null Values to a Required Field

Sending Null Values to a Required Field


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_sourceDefine strSQLconn.Execute strSQLconn.Close Set conn = Nothing 

Can you tell me what I’m doing wrong?


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.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several