Can't have zero-length string in a database field?

J

johnb41

I have a simple form that has a bunch of textboxes that show data from
a dataset table.

When I "Add" a record with BindingManagerBase.AddNew(), all the
textboxes go blank, so I can add a new record.

If I leave a field totally blank, and then click the Update button
(which uses the DataAdapter.Update() command, I get an error saying:

"Field 'Orders.Email' cannot be a zero-length string"

Does .NET not allow zero-length strings?

I tried programmatically adding a space (" ") to the textbox like this:

If tbEmail.Text = "" Then
tbEmail.Text = " "
'also tried tbEmail.text = chr(32)
'also tried tbEmail.text = vbnull
End If

But after I get the error, this textbox still has no space in it.

I'm stumped. Can someone help?

Thanks!
John
 
B

Bernie Yaeger

Hi John,

It's .net that's disallowing the add - it's your database. What is the
backend? What are the characteristics of the email column? Are you
updating using the commandbuilder or using manual update commands?

HTH,

Bernie Yaeger
 
H

Hal Rosser

its most likely the database:
for instance, the northwind database has some fields where 'allow null' is
true, but 'allow zero length' is false.
in other words, you can put null in the field - but not an empty string -
--- moral of the story - check the database , modify your code to set the
fields to null rather than an empty string
HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top