[Mono-bugs] [Bug 608491] OdbcCommand Parameters Collection fails to set size when setting Value

2011-06-10 Thread bugzilla_noreply

https://bugzilla.novell.com/show_bug.cgi?id=608491

https://bugzilla.novell.com/show_bug.cgi?id=608491#c4


--- Comment #4 from Richard Kettlewell 
richard.kettlew...@thales-esecurity.com 2011-06-10 11:11:42 UTC ---
Created an attachment (id=433962)
 -- (http://bugzilla.novell.com/attachment.cgi?id=433962)
Compute a default size

I have run into the same problem.  The patch I'm using is attached.  It works
for us; as the code comment indicates, a completely general fix is tricky to
achieve.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the QA contact for the bug.
___
mono-bugs maillist  -  mono-bugs@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-bugs


[Mono-bugs] [Bug 608491] OdbcCommand Parameters Collection fails to set size when setting Value

2011-05-25 Thread bugzilla_noreply

https://bugzilla.novell.com/show_bug.cgi?id=608491

https://bugzilla.novell.com/show_bug.cgi?id=608491#c


Richard Kettlewell 0richardkk.nov...@chiark.greenend.org.uk changed:

   What|Removed |Added

 CC||0richardkk.nov...@chiark.gr
   ||eenend.org.uk

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the QA contact for the bug.
___
mono-bugs maillist  -  mono-bugs@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-bugs


[Mono-bugs] [Bug 608491] OdbcCommand Parameters Collection fails to set size when setting Value

2010-06-10 Thread bugzilla_noreply
http://bugzilla.novell.com/show_bug.cgi?id=608491

http://bugzilla.novell.com/show_bug.cgi?id=608491#c


Veerapuram Varadhan vvarad...@novell.com changed:

   What|Removed |Added

 CC||vvarad...@novell.com
 AssignedTo|mono-bugs@lists.ximian.com  |vvarad...@novell.com

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the QA contact for the bug.
You are the assignee for the bug.
___
mono-bugs maillist  -  mono-bugs@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-bugs


[Mono-bugs] [Bug 608491] OdbcCommand Parameters Collection fails to set size when setting Value

2010-05-29 Thread bugzilla_noreply
http://bugzilla.novell.com/show_bug.cgi?id=608491

http://bugzilla.novell.com/show_bug.cgi?id=608491#c3


Zoltan Varga var...@gmail.com changed:

   What|Removed |Added

  Component|io-layer|Sys.Data
 AssignedTo|lu...@novell.com|mono-bugs@lists.ximian.com
Product|Mono: Runtime   |Mono: Class Libraries

--- Comment #3 from Zoltan Varga var...@gmail.com 2010-05-29 16:02:39 UTC ---
- sys.data

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the QA contact for the bug.
You are the assignee for the bug.
___
mono-bugs maillist  -  mono-bugs@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-bugs


[Mono-bugs] [Bug 608491] OdbcCommand Parameters Collection fails to set size when setting Value

2010-05-25 Thread bugzilla_noreply
http://bugzilla.novell.com/show_bug.cgi?id=608491

http://bugzilla.novell.com/show_bug.cgi?id=608491#c1


Bobby White bobbywhit...@yahoo.com changed:

   What|Removed |Added

 CC||bobbywhit...@yahoo.com

--- Comment #1 from Bobby White bobbywhit...@yahoo.com 2010-05-25 13:46:55 
UTC ---
(In reply to comment #0)
 Created an attachment (id=364356)
 -- (http://bugzilla.novell.com/attachment.cgi?id=364356) [details]
 A short sample program to reproduce the bug
 
 User-Agent:   Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9)
 Gecko/20100315 (CK-IBM) Firefox/3.5.9 ( .NET CLR 3.5.30729; .NET4.0E)
 
 Using the System.Data.Odbc package in the Mono 2.4.2 runtime
 
 When running any SQL the requires Parameter markers and parameter binding,  
 the
 call to set the Value of the parameter fails to properly set the length 
 causing
 the Value to be truncated.
 
 OdbcConnection myConnection = new OdbcConnection(connectString);
 myConnection.Open();
 OdbcCommand cmd = myConnection.CreateCommand();
 cmd.CommandText = INSERT INTO myTable (col1) VALUES(?);
 
 cmd.Parameters.Add(@col1Value,OdbcType.VarChar).Value(myNewValue);
 
 // the above should have set the Size, but it doesn't
 
 
 
 Reproducible: Always
 
 Steps to Reproduce:
 1. Open an OdbcConnection
 2. Create an OdbcCommand
 3. Set the CommandText to an SQL statement with a Parameter marker ?
 4. Add a parameter to the OdbcCommand.Parameters collection
 5. Set the value of that Parameter (but dont' explicitly set the length)
 Actual Results:  
 With the Informix database, you get an Exception:
 Odbc Parameter Test
 OdbcException: ERROR [22001] [unixODBC][String data right truncation.]
 ErrorCode: -2147467259
 SQL State: 22001
 Native Error: -11023
 
 
 Expected Results:  
 A valid OdbcDataReader() containing results.


To further clarify, this behavior isn't limited to a single database, it also
happens for others such as Microsoft SQL Server AND the behavior is different
than native Microsoft .Net when run on windows.

Both, MS Framework and Mono don't set the .Size of the parameter, but the
difference between the two, is that Microsoft is clever and sets the ColSize
of for the SQLBindParameter() ODBC API, when Mono doesnt. 

This is the source code of the Mono Bind() 


ret = libodbc.SQLBindParameter (hstmt, (ushort) ParamNum, (short) paramdir, 
 _typeMap.NativeType, _typeMap.SqlType, Convert.ToUInt32 (Size), 0, (IntPtr)
_nativeBuffer, 0, _cbLengthInd); 

6th element (Size) is taken directly from the .Size attribute of the
OdbcParameter object, which was never set. 


Microsoft framework does it this way: 

ODBC32.RetCode retcode = hstmt.BindParameter(ordinal, (short)
sql_param, sql_c, this._bindtype._sql_type, (IntPtr) num4, (IntPtr)
parameterScale, buffer, (IntPtr) this._preparedBufferSize, intbuffer); 

The 6th one, num4 is initialize with the Column size: 

internal void Bind(OdbcStatementHandle hstmt, OdbcCommand command, short
ordinal, CNativeBuffer parameterBuffer, bool allowReentrance) 
{ 
ODBC32.SQL_C sql_c = this._prepared_Sql_C_Type; 
ODBC32.SQL_PARAM sql_param = this.SqlDirectionFromParameterDirection(); 
int offset = this._preparedOffset; 
int sizeorprecision = this._preparedSize; 
object obj2 = this._preparedValue; 
int valueSize = this.GetValueSize(obj2, offset); 
int num4 = this.GetColumnSize(obj2, offset, ordinal); 


So, it means Microsoft will always send the size of the column to the
SQLBindParameter api, even if the .Size of the Parameter is not manually set.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the QA contact for the bug.
___
mono-bugs maillist  -  mono-bugs@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-bugs