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!

Error adding record to DB if a field is empty

Status
Not open for further replies.

jimmywages

Programmer
Dec 12, 2002
11
0
0
US
Note: this was posted in the VBScript forum, but someone told me this is a more appropriate forum for it... so I'm posting it here again. Hope that's okay!

-----

Hello,

I am trying to add a record to a database by using the following code:

oRS.Open "select * from myTable", oConn, 1, 3
oRS.AddNew
oRS("TextBody") = ""
oRS.Update

(I cut out some lines that are irrelevant to the problem at hand) So what happens is that it gives me this error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver]Error in row
/cline/add_done.asp, line 34

Line 34 is where the oRS.Update line is. However, when I tried changing TextBody so that it gets " " (a space) instead of "" (empty string), it works!

So for some reason, it doesn't like the empty string. I checked my Access Database and it clearly says REQUIRED: NO! So if it's not a required field, why can't it accept an empty string?

Any ideas? Thanks in advance for any help.

~jimmy.
 
Whoops! I figured it out. Other than the "REQUIRED" property there is also a "ALLOW ZERO LENGTH" property, which must be set to "YES".

~jimmy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top