Hi Michael,

I'm having trouble reproducing this, and wonder it it might be a bug
in Sybase ADO.Net provider that is now fixed. I'm using
Sybase.AdoNet2.AseClient.dll, file version 2.157.401.0. With this
version parameter.Size remains zero even after the string value has
been set.


/Oskar


2012/12/10 Oskar Berggren <[email protected]>:
> For IDbDataParameter.Size we have the following documentation on MSDN:
> The maximum size, in bytes, of the data within the column. The default
> value is inferred from the the parameter value.
>
> While for DbParameter.Size (which implements the above) we have (excerpt):
> The DbType and Size properties of a parameter can be inferred by
> setting Value. Therefore, you are not required to specify them.
> However, they are not exposed in DbParameter property settings. For
> example, if the size of the parameter has been inferred, Size does not
> contain inferred value after statement execution.
>
> NHibernate (in AbstractStringType) relies on the behavior in the last
> sentence above: Size does not contain inferred value after statement
> execution.
>
> I don't now if the Sybase provider inherits from DbParameter or
> implement IDbDataParameter directly, but in either case it has
> different behavior, namely exposing an inferred Size value. What we
> can try to fix this is to make the SybaseAseClientDriver set an
> explicit parameter  length. If you want to experiment with this, you
> should subclass the driver and override GenerateCommand() - see
> SqlClientDriver for inspiration. I don't have Sybase myself so it
> would be great if you could look into this.
>
> /Oskar
>
>
> 2012/11/19 Michael Fan <[email protected]>:
>> I could not believe it in the beginning. But that is the fact.
>>
>> I was updating a collection into a database table. One of the field in the
>> collection is a string type.
>> I debugged into nHibernate 3.3.1 code, (see my initial post). My column
>> width in the table (hbm mapped) is 220. But I found that parameter.Size ,
>> which should have been set to 220 , was actually set to 15, which is the
>> length of the string "Atlanta AAA Ltd", the value of this field at the first
>> row of the collection.
>> I set the string other length as well, parameter.Size was always set to that
>> length.
>>
>> I could not debug any furthur into IDbDataParameter , because I don't have
>> the source code.
>>
>> Michael Fan
>>
>> =========================
>> On Monday, November 19, 2012 11:07:29 AM UTC-5, Oskar Berggren wrote:
>>>
>>> 2012/11/19 Michael Fan <[email protected]>
>>>
>>> > IDbDataParameter parameter.Size is set to the length of the string of
>>> > the first row in collection, instead of the column size defined in the 
>>> > table
>>>
>>> How do you conclude "set to the length of the string of the first row
>>> in collection"? I don't quite get that part.
>>>
>>> NH will not set the parameter size according to the column size in the
>>> table, but some drivers will set the parameter size based on the
>>> length attribute from your mapping. However, the SybaseAseClientDriver
>>> does not appear to do that.
>>>
>>>
>>> Could it be that the Sybase ADO.NET provider has a provider specific
>>> behavior of changing parameter.Size when the value is assigned?
>>>
>>> /Oskar
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/nhusers/-/Q244PhTV6eYJ.
>>
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to