Google Groups Home
Help | Sign in
"No size set for variable length data" Oracle update error with empty string in .NET
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
arvee  
View profile
 More options Apr 7 2005, 12:22 pm
Newsgroups: comp.databases.oracle, microsoft.public.dotnet.framework.adonet
From: "arvee" <nos...@spam.not>
Date: Thu, 07 Apr 2005 16:22:34 GMT
Local: Thurs, Apr 7 2005 12:22 pm
Subject: "No size set for variable length data" Oracle update error with empty string in .NET
Hi - I'm updating an Oracle table with an empty string and getting the
error:

An unhandled exception of type 'System.Exception' occurred in
system.data.dll
Additional information: Parameter 'p1': No size set for variable length data
type: String.

The column is nullable and of type varchar2(50).  I'm aware that I can store
DBNull.Value instead and Oracle won't complain, but, I was hoping to avoid
testing and converting for that condition.  It seems the .NET class lib
should handle empty strings, no?  There are times I'd like to throw the
dataset into a datagrid control and have the user have there way with it,
therefore, its not ideal to have to validate each string value on the
update.

Question 1: Is this a bug or am I doing something wrong?
Question 2: If its a bug, is there an elegant workaround?

Sample C# code is:

// create typed dataset (basic customer list: name, address, phone, etc.)
CustomerDS dsCustomer = new CustomerDS();

// create data adapter
OracleDataAdapter daCustomers = new OracleDataAdapter("SELECT * FROM
Customers", connectionString);

// use command builder to create update, insert and delete commands based on
select
OracleCommandBuilder cb = new OracleCommandBuilder(daCustomers);

// get some data
daCustomers.Fill(dsCustomer.CUSTOMERS)

// delete Middle Name, for example
dsCustomer.CUSTOMERS.Rows[0]["MIDDLE_NAME"] = "";

// store new dataset
daCustomers.Update(dsCustomer, "Customers");

// boom - get error (even though I put it in a try...catch block!)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frank van Bortel  
View profile
 More options Apr 8 2005, 7:46 am
Newsgroups: comp.databases.oracle, microsoft.public.dotnet.framework.adonet
From: Frank van Bortel <fvanbor...@netscape.net>
Date: Fri, 08 Apr 2005 13:46:24 +0200
Local: Fri, Apr 8 2005 7:46 am
Subject: Re: "No size set for variable length data" Oracle update error with empty string in .NET
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[snip!]
Why don't you store a NULL? Oracle will treat '' (empty string) as
NULL, and store as NULL anyway - better be prepared for it, and
treat it as such.

Oh yes - it will work when you let Oracle do the conversion(s), but
some understanding of the product you are working with will only
help you in creating a better product.

All documentation is on docs.oracle.com - free! Start with Concepts.

- --
Regards,
Frank van Bortel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCVm8QfyJ9XXMPY5URArK8AKCRsSGLCWO9VYv3YnUqLcX2rYE1DACfTcCO
f8j04ChsvUGatK4rAjP0wzY=
=nBQ1
-----END PGP SIGNATURE-----


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google