I think you are going to need Curt's solution #2 and explicitly create a "byte array".
Let us know if that works. If it does, we could also consider adding to IronPython.Runtime.PythonBuffer (the class which implements buffer<http://www.python.org/doc/2.5.1/api/bufferObjects.html>) an implicit conversion operator to "byte array". With a few tweaks to System.Scripting.Com.VarEnumSelector, we could get to a point where you should be able to just do "p.AppendChunk<http://msdn.microsoft.com/en-us/library/ms678268(VS.85).aspx>(elem)" and have elem converted from a buffer<http://www.python.org/doc/2.5.1/api/bufferObjects.html> to "VT_ARRAY | VT_I1" From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Curt Hagenlocher Sent: Wednesday, August 27, 2008 8:51 PM To: Discussion of IronPython Subject: Re: [IronPython] What is .AppendChunk expecting? Two more ideas: 1) Try passing a list of numbers. You can trivially get this from the buffer by saying a = map(lambda c: ord(c), buf) 2) Try passing a BCL array of bytes. This is almost as easy: import System a = System.Array[System.Byte](map(lambda c: ord(c), b)) On Wed, Aug 27, 2008 at 7:36 PM, Vernon Cole <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>> wrote: I tried both p.AppendChunk(str(elem)) and p.AppendChunk(unicode(elem)) both of which work, but then the execution fails with: <console output> File "C:\Program Files\IronPython 2.0 Beta4\lib\site-packages\adodbapi\adodbapi.py", line 675, in _executeHelper rs = self.cmd.Execute(ra) EnvironmentError: The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. -- on command: "INSERT INTO tblTemp (fldId,fldData) VALUES (?,?)" -- with parameters: (2, <read-only buffer for 0x000000000000003A, size 4, offset 0 at 0x000000000000003B>) </console output> which lead me to believe that I'm not giving .AppendChunk() the argument it expects. I even tried p.Value = elem which results in: StandardError: Exception has been thrown by the target of an invocation. -- Vernon On Wed, Aug 27, 2008 at 7:40 PM, Curt Hagenlocher <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>> wrote: This will probably need to be a string. I don't think we do any automatic conversions of buffer objects for CLR or COM calls. On Wed, Aug 27, 2008 at 6:28 PM, Vernon Cole <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>> wrote: Dear miracle workers: This may actually be the last failed unittest for adodbapai. Progress has been remarkable. Can you help with one more? Situation: filling in the parameter list for an ADO execute. The second parameter (parameter 1) is a python "buffer" to be loaded into a binary(4) column. "elem" contains the value of the parameter. "p" is the parameter object. Pywin32 uses p.AppendChunk successfully to pass the buffer to SQL, but Iron objects: <console output> DatabaseError: --ADODBAPI -- Trying parameter 1 = <read-only buffer for 0x000000000000003A, size 4, offset 0 at 0x000000000000003B> Traceback (most recent call last): File "C:\Program Files\IronPython 2.0 Beta4\lib\site-packages\adodbapi\adodba pi.py", line 659, in _executeHelper p.AppendChunk(elem) TypeError: Specified cast is not valid. -- on command: "INSERT INTO tblTemp (fldId,fldData) VALUES (?,?)" -- with parameters: (2, <read-only buffer for 0x000000000000003A, size 4, offset 0 at 0x000000000000003B>) </console output> What coercion should be supplied to make AppendChunk happy to accept the buffer contents without trying to cast it? -- Vernon Cole _______________________________________________ Users mailing list Users@lists.ironpython.com<mailto:Users@lists.ironpython.com> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list Users@lists.ironpython.com<mailto:Users@lists.ironpython.com> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list Users@lists.ironpython.com<mailto:Users@lists.ironpython.com> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com