Updating an empty databound multiline textbox

J

Joshua Ellul

Hi There,

I have databound a multiline textbox to a memo field in an access database.
When the multiline textbox's value is nullstring ("") the Update command of
the associated Adapter fails. (The field that the multiline textbox is
databound to allows Null values).

Any ideas? Perhaps a bug?

Josh
 
N

Nicole Calinoiu

Josh,

Access also defines an "allow zero-length" property for text and memo
columns. Could the setting applied for this property be the problem here?

HTH,
Nicole
 
N

Nicole Calinoiu

Josh,

I'm not sure from your answer if you understand the implications of this so,
just in case... AllowZeroLength = true means that a zero-length string
cannot be used as a value in the column. This is pretty much the same thing
as using a check constraint like the following: [column] <> ''. You'll
either need to change the property to allow zero-length strings (but watch
out for potential impact on existing queries that might assume that there
are no empty strings present) or avoid passing empty strings into the
column.

HTH,
Nicole
 
J

Joshua Ellul

AllowZeroLength = True means that zero length strings are allowed... ;)

Josh

Nicole Calinoiu said:
Josh,

I'm not sure from your answer if you understand the implications of this so,
just in case... AllowZeroLength = true means that a zero-length string
cannot be used as a value in the column. This is pretty much the same thing
as using a check constraint like the following: [column] <> ''. You'll
either need to change the property to allow zero-length strings (but watch
out for potential impact on existing queries that might assume that there
are no empty strings present) or avoid passing empty strings into the
column.

HTH,
Nicole


Joshua Ellul said:
Hi Nicole,

The AllowZeroLength is also set to true

Thanks,

Josh
 
N

Nicole Calinoiu

Sorry, late Friday brain scramble... What's the update command on your
dataadapter? What exception do you see when the update fails?



Joshua Ellul said:
AllowZeroLength = True means that zero length strings are allowed... ;)

Josh

Nicole Calinoiu said:
Josh,

I'm not sure from your answer if you understand the implications of this so,
just in case... AllowZeroLength = true means that a zero-length string
cannot be used as a value in the column. This is pretty much the same thing
as using a check constraint like the following: [column] <> ''. You'll
either need to change the property to allow zero-length strings (but watch
out for potential impact on existing queries that might assume that there
are no empty strings present) or avoid passing empty strings into the
column.

HTH,
Nicole


Joshua Ellul said:
Hi Nicole,

The AllowZeroLength is also set to true

Thanks,

Josh

Josh,

Access also defines an "allow zero-length" property for text and memo
columns. Could the setting applied for this property be the problem here?

HTH,
Nicole


Hi There,

I have databound a multiline textbox to a memo field in an access
database.
When the multiline textbox's value is nullstring ("") the Update command
of
the associated Adapter fails. (The field that the multiline
textbox
is
databound to allows Null values).

Any ideas? Perhaps a bug?

Josh
 
J

Joshua Ellul

Np,

I managed to solve the problem (by solving another problem).

I had a databound datetimepicker that was not allowing me to perform .AddNew
operations... I changed the databinding from the Value property to the Text
property, this solved both problems, it must have somehow been conflicting
with this databinding :S

Thanks for your help :)

Josh

Nicole Calinoiu said:
Sorry, late Friday brain scramble... What's the update command on your
dataadapter? What exception do you see when the update fails?



Joshua Ellul said:
AllowZeroLength = True means that zero length strings are allowed... ;)

Josh

Nicole Calinoiu said:
Josh,

I'm not sure from your answer if you understand the implications of
this
so,
just in case... AllowZeroLength = true means that a zero-length string
cannot be used as a value in the column. This is pretty much the same thing
as using a check constraint like the following: [column] <> ''. You'll
either need to change the property to allow zero-length strings (but watch
out for potential impact on existing queries that might assume that there
are no empty strings present) or avoid passing empty strings into the
column.

HTH,
Nicole


Hi Nicole,

The AllowZeroLength is also set to true

Thanks,

Josh

Josh,

Access also defines an "allow zero-length" property for text and memo
columns. Could the setting applied for this property be the problem
here?

HTH,
Nicole


Hi There,

I have databound a multiline textbox to a memo field in an access
database.
When the multiline textbox's value is nullstring ("") the Update
command
of
the associated Adapter fails. (The field that the multiline textbox
is
databound to allows Null values).

Any ideas? Perhaps a bug?

Josh
 
J

Joshua Ellul

Actually, Ignore my last post, it's still crashing ....

Here's how the adapter is set up:

SqlStr = "SELECT * FROM Persons WHERE PersonId = 1"
myCon = New OleDb.OleDbConnection(g.DBStr)
myAdapter = New OleDb.OleDbDataAdapter(SqlStr, myCon)
myAdapter.Fill(myDS, myDataTable)
Dim myBuilder As New OleDb.OleDbCommandBuilder(myAdapter)
myAdapter.UpdateCommand = myBuilder.GetUpdateCommand
myAdapter.InsertCommand = myBuilder.GetInsertCommand
myAdapter.DeleteCommand = myBuilder.GetDeleteCommand
myCon.Close()

It allows me to save if the text field has data, however, if its empty the
following error is raised:
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll


It is raised on the line:
myAdapter.Update(myDS, "Persons")

Josh

Nicole Calinoiu said:
Sorry, late Friday brain scramble... What's the update command on your
dataadapter? What exception do you see when the update fails?



Joshua Ellul said:
AllowZeroLength = True means that zero length strings are allowed... ;)

Josh

Nicole Calinoiu said:
Josh,

I'm not sure from your answer if you understand the implications of
this
so,
just in case... AllowZeroLength = true means that a zero-length string
cannot be used as a value in the column. This is pretty much the same thing
as using a check constraint like the following: [column] <> ''. You'll
either need to change the property to allow zero-length strings (but watch
out for potential impact on existing queries that might assume that there
are no empty strings present) or avoid passing empty strings into the
column.

HTH,
Nicole


Hi Nicole,

The AllowZeroLength is also set to true

Thanks,

Josh

Josh,

Access also defines an "allow zero-length" property for text and memo
columns. Could the setting applied for this property be the problem
here?

HTH,
Nicole


Hi There,

I have databound a multiline textbox to a memo field in an access
database.
When the multiline textbox's value is nullstring ("") the Update
command
of
the associated Adapter fails. (The field that the multiline textbox
is
databound to allows Null values).

Any ideas? Perhaps a bug?

Josh
 
J

Joshua Ellul

I've changed the textbox's multline property to false and it still doesn't
work... I presume the problem is from the database.

In changing the Field's Type to text it works, however if it is memo it
doesn't :S

Josh

Joshua Ellul said:
Actually, Ignore my last post, it's still crashing ....

Here's how the adapter is set up:

SqlStr = "SELECT * FROM Persons WHERE PersonId = 1"
myCon = New OleDb.OleDbConnection(g.DBStr)
myAdapter = New OleDb.OleDbDataAdapter(SqlStr, myCon)
myAdapter.Fill(myDS, myDataTable)
Dim myBuilder As New OleDb.OleDbCommandBuilder(myAdapter)
myAdapter.UpdateCommand = myBuilder.GetUpdateCommand
myAdapter.InsertCommand = myBuilder.GetInsertCommand
myAdapter.DeleteCommand = myBuilder.GetDeleteCommand
myCon.Close()

It allows me to save if the text field has data, however, if its empty the
following error is raised:
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll


It is raised on the line:
myAdapter.Update(myDS, "Persons")

Josh

Nicole Calinoiu said:
Sorry, late Friday brain scramble... What's the update command on your
dataadapter? What exception do you see when the update fails?



Joshua Ellul said:
AllowZeroLength = True means that zero length strings are allowed... ;)

Josh

Josh,

I'm not sure from your answer if you understand the implications of this
so,
just in case... AllowZeroLength = true means that a zero-length string
cannot be used as a value in the column. This is pretty much the same
thing
as using a check constraint like the following: [column] <> ''. You'll
either need to change the property to allow zero-length strings (but watch
out for potential impact on existing queries that might assume that there
are no empty strings present) or avoid passing empty strings into the
column.

HTH,
Nicole


Hi Nicole,

The AllowZeroLength is also set to true

Thanks,

Josh

Josh,

Access also defines an "allow zero-length" property for text and memo
columns. Could the setting applied for this property be the problem
here?

HTH,
Nicole


Hi There,

I have databound a multiline textbox to a memo field in an access
database.
When the multiline textbox's value is nullstring ("") the Update
command
of
the associated Adapter fails. (The field that the multiline textbox
is
databound to allows Null values).

Any ideas? Perhaps a bug?

Josh
 
N

Nicole Calinoiu

Josh,

I've tried to reproduce the problem, but I haven't had any luck. With a
textbox (multi-line or not) bound to an Access memo column, I have no
problem persisting an empty string to the database. Which versions of the
following are you using?

1. Access (i.e.: the version of Access for which your database was created)
2. MDAC/ADO
3. .NET framework

And lastly, what's the connection string you're using to connect to the
database?

Nicole


Joshua Ellul said:
I've changed the textbox's multline property to false and it still doesn't
work... I presume the problem is from the database.

In changing the Field's Type to text it works, however if it is memo it
doesn't :S

Josh

Joshua Ellul said:
Actually, Ignore my last post, it's still crashing ....

Here's how the adapter is set up:

SqlStr = "SELECT * FROM Persons WHERE PersonId = 1"
myCon = New OleDb.OleDbConnection(g.DBStr)
myAdapter = New OleDb.OleDbDataAdapter(SqlStr, myCon)
myAdapter.Fill(myDS, myDataTable)
Dim myBuilder As New OleDb.OleDbCommandBuilder(myAdapter)
myAdapter.UpdateCommand = myBuilder.GetUpdateCommand
myAdapter.InsertCommand = myBuilder.GetInsertCommand
myAdapter.DeleteCommand = myBuilder.GetDeleteCommand
myCon.Close()

It allows me to save if the text field has data, however, if its empty the
following error is raised:
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll


It is raised on the line:
myAdapter.Update(myDS, "Persons")

Josh

Nicole Calinoiu said:
Sorry, late Friday brain scramble... What's the update command on your
dataadapter? What exception do you see when the update fails?



AllowZeroLength = True means that zero length strings are allowed... ;)

Josh

Josh,

I'm not sure from your answer if you understand the implications
of
this
so,
just in case... AllowZeroLength = true means that a zero-length string
cannot be used as a value in the column. This is pretty much the same
thing
as using a check constraint like the following: [column] <> ''. You'll
either need to change the property to allow zero-length strings (but
watch
out for potential impact on existing queries that might assume that
there
are no empty strings present) or avoid passing empty strings into the
column.

HTH,
Nicole


Hi Nicole,

The AllowZeroLength is also set to true

Thanks,

Josh

Josh,

Access also defines an "allow zero-length" property for text and
memo
columns. Could the setting applied for this property be the problem
here?

HTH,
Nicole


Hi There,

I have databound a multiline textbox to a memo field in an access
database.
When the multiline textbox's value is nullstring ("") the Update
command
of
the associated Adapter fails. (The field that the multiline
textbox
is
databound to allows Null values).

Any ideas? Perhaps a bug?

Josh
 
J

Joshua Ellul

So,

I'm using an Access 2002 (XP) DB,
Not sure on the version of MDAC / ADO (how do I check it in .NET?)
(in vb I have up till ActiveX Data Objects 2.7)

..Net Framework 1.0 (Version 1.0.3705)

Josh

Nicole Calinoiu said:
Josh,

I've tried to reproduce the problem, but I haven't had any luck. With a
textbox (multi-line or not) bound to an Access memo column, I have no
problem persisting an empty string to the database. Which versions of the
following are you using?

1. Access (i.e.: the version of Access for which your database was created)
2. MDAC/ADO
3. .NET framework

And lastly, what's the connection string you're using to connect to the
database?

Nicole


Joshua Ellul said:
I've changed the textbox's multline property to false and it still doesn't
work... I presume the problem is from the database.

In changing the Field's Type to text it works, however if it is memo it
doesn't :S

Josh

Joshua Ellul said:
Actually, Ignore my last post, it's still crashing ....

Here's how the adapter is set up:

SqlStr = "SELECT * FROM Persons WHERE PersonId = 1"
myCon = New OleDb.OleDbConnection(g.DBStr)
myAdapter = New OleDb.OleDbDataAdapter(SqlStr, myCon)
myAdapter.Fill(myDS, myDataTable)
Dim myBuilder As New OleDb.OleDbCommandBuilder(myAdapter)
myAdapter.UpdateCommand = myBuilder.GetUpdateCommand
myAdapter.InsertCommand = myBuilder.GetInsertCommand
myAdapter.DeleteCommand = myBuilder.GetDeleteCommand
myCon.Close()

It allows me to save if the text field has data, however, if its empty the
following error is raised:
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll


It is raised on the line:
myAdapter.Update(myDS, "Persons")

Josh

Sorry, late Friday brain scramble... What's the update command on your
dataadapter? What exception do you see when the update fails?



AllowZeroLength = True means that zero length strings are
allowed...
;)
Josh

Josh,

I'm not sure from your answer if you understand the implications of
this
so,
just in case... AllowZeroLength = true means that a zero-length
string
cannot be used as a value in the column. This is pretty much
the
same
thing
as using a check constraint like the following: [column] <> ''.
You'll
either need to change the property to allow zero-length strings (but
watch
out for potential impact on existing queries that might assume that
there
are no empty strings present) or avoid passing empty strings
into
the
column.

HTH,
Nicole


Hi Nicole,

The AllowZeroLength is also set to true

Thanks,

Josh

Josh,

Access also defines an "allow zero-length" property for text and
memo
columns. Could the setting applied for this property be the
problem
here?

HTH,
Nicole


Hi There,

I have databound a multiline textbox to a memo field in an
access
database.
When the multiline textbox's value is nullstring ("") the Update
command
of
the associated Adapter fails. (The field that the multiline
textbox
is
databound to allows Null values).

Any ideas? Perhaps a bug?

Josh
 
N

Nicole Calinoiu

And the connection string?


Joshua Ellul said:
So,

I'm using an Access 2002 (XP) DB,
Not sure on the version of MDAC / ADO (how do I check it in .NET?)
(in vb I have up till ActiveX Data Objects 2.7)

.Net Framework 1.0 (Version 1.0.3705)

Josh

Nicole Calinoiu said:
Josh,

I've tried to reproduce the problem, but I haven't had any luck. With a
textbox (multi-line or not) bound to an Access memo column, I have no
problem persisting an empty string to the database. Which versions of the
following are you using?

1. Access (i.e.: the version of Access for which your database was created)
2. MDAC/ADO
3. .NET framework

And lastly, what's the connection string you're using to connect to the
database?

Nicole


Joshua Ellul said:
I've changed the textbox's multline property to false and it still doesn't
work... I presume the problem is from the database.

In changing the Field's Type to text it works, however if it is memo it
doesn't :S

Josh

Actually, Ignore my last post, it's still crashing ....

Here's how the adapter is set up:

SqlStr = "SELECT * FROM Persons WHERE PersonId = 1"
myCon = New OleDb.OleDbConnection(g.DBStr)
myAdapter = New OleDb.OleDbDataAdapter(SqlStr, myCon)
myAdapter.Fill(myDS, myDataTable)
Dim myBuilder As New OleDb.OleDbCommandBuilder(myAdapter)
myAdapter.UpdateCommand = myBuilder.GetUpdateCommand
myAdapter.InsertCommand = myBuilder.GetInsertCommand
myAdapter.DeleteCommand = myBuilder.GetDeleteCommand
myCon.Close()

It allows me to save if the text field has data, however, if its
empty
the
following error is raised:
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll


It is raised on the line:
myAdapter.Update(myDS, "Persons")

Josh

Sorry, late Friday brain scramble... What's the update command on your
dataadapter? What exception do you see when the update fails?



AllowZeroLength = True means that zero length strings are allowed...
;)

Josh

Josh,

I'm not sure from your answer if you understand the
implications
of
this
so,
just in case... AllowZeroLength = true means that a zero-length
string
cannot be used as a value in the column. This is pretty much the
same
thing
as using a check constraint like the following: [column] <> ''.
You'll
either need to change the property to allow zero-length
strings
(but
watch
out for potential impact on existing queries that might assume that
there
are no empty strings present) or avoid passing empty strings into
the
column.

HTH,
Nicole


Hi Nicole,

The AllowZeroLength is also set to true

Thanks,

Josh

Josh,

Access also defines an "allow zero-length" property for
text
and
memo
columns. Could the setting applied for this property be the
problem
here?

HTH,
Nicole


Hi There,

I have databound a multiline textbox to a memo field in an
access
database.
When the multiline textbox's value is nullstring ("") the
Update
command
of
the associated Adapter fails. (The field that the multiline
textbox
is
databound to allows Null values).

Any ideas? Perhaps a bug?

Josh
 
J

Joshua Ellul

Public DBStr As String = "Provider=Microsoft.JET.OLEDB.4.0;Data
Source=MyDB.mdb"

Nicole Calinoiu said:
And the connection string?


Joshua Ellul said:
So,

I'm using an Access 2002 (XP) DB,
Not sure on the version of MDAC / ADO (how do I check it in .NET?)
(in vb I have up till ActiveX Data Objects 2.7)

.Net Framework 1.0 (Version 1.0.3705)

Josh

Nicole Calinoiu said:
Josh,

I've tried to reproduce the problem, but I haven't had any luck. With a
textbox (multi-line or not) bound to an Access memo column, I have no
problem persisting an empty string to the database. Which versions of the
following are you using?

1. Access (i.e.: the version of Access for which your database was created)
2. MDAC/ADO
3. .NET framework

And lastly, what's the connection string you're using to connect to the
database?

Nicole


I've changed the textbox's multline property to false and it still doesn't
work... I presume the problem is from the database.

In changing the Field's Type to text it works, however if it is memo it
doesn't :S

Josh

Actually, Ignore my last post, it's still crashing ....

Here's how the adapter is set up:

SqlStr = "SELECT * FROM Persons WHERE PersonId = 1"
myCon = New OleDb.OleDbConnection(g.DBStr)
myAdapter = New OleDb.OleDbDataAdapter(SqlStr, myCon)
myAdapter.Fill(myDS, myDataTable)
Dim myBuilder As New OleDb.OleDbCommandBuilder(myAdapter)
myAdapter.UpdateCommand = myBuilder.GetUpdateCommand
myAdapter.InsertCommand = myBuilder.GetInsertCommand
myAdapter.DeleteCommand = myBuilder.GetDeleteCommand
myCon.Close()

It allows me to save if the text field has data, however, if its empty
the
following error is raised:
An unhandled exception of type 'System.InvalidOperationException'
occurred
in system.data.dll


It is raised on the line:
myAdapter.Update(myDS, "Persons")

Josh

Sorry, late Friday brain scramble... What's the update command on
your
dataadapter? What exception do you see when the update fails?



AllowZeroLength = True means that zero length strings are allowed...
;)

Josh

Josh,

I'm not sure from your answer if you understand the implications
of
this
so,
just in case... AllowZeroLength = true means that a zero-length
string
cannot be used as a value in the column. This is pretty
much
the
same
thing
as using a check constraint like the following: [column] <> ''.
You'll
either need to change the property to allow zero-length strings
(but
watch
out for potential impact on existing queries that might assume
that
there
are no empty strings present) or avoid passing empty strings into
the
column.

HTH,
Nicole


Hi Nicole,

The AllowZeroLength is also set to true

Thanks,

Josh

Josh,

Access also defines an "allow zero-length" property for text
and
memo
columns. Could the setting applied for this property be the
problem
here?

HTH,
Nicole


Hi There,

I have databound a multiline textbox to a memo field
in
 
N

Nicole Calinoiu

Josh,

I cannot reproduce the error even with a similar system configuration. This
would suggest that the problem lies somewhere in your code, not in the
behind-the-scenes database interaction. You might want to try using the
data form wizard to create a similar form then, assuming the generated form
does not have the same problem, figure out what it's doing differently from
your own code.

HTH,
Nicole



Joshua Ellul said:
Public DBStr As String = "Provider=Microsoft.JET.OLEDB.4.0;Data
Source=MyDB.mdb"

Nicole Calinoiu said:
And the connection string?
With
a of
the memo
it
command
on
your
dataadapter? What exception do you see when the update fails?



AllowZeroLength = True means that zero length strings are
allowed...
;)

Josh

Josh,

I'm not sure from your answer if you understand the implications
of
this
so,
just in case... AllowZeroLength = true means that a zero-length
string
cannot be used as a value in the column. This is pretty much
the
same
thing
as using a check constraint like the following: [column]
for
text be
the in ("")
the
 

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