Dino: Here is the repo. You were using ADODB.RecordSet. This is ADODB.Command. <Python> """exercise BINARY field bug"""
_computername=".\SQLexpress" #or name of computer with SQL Server _databasename="Northwind" #or something else constr = r"Initial Catalog=%s; Data Source=%s; Provider=SQLOLEDB.1; Integrated Security=SSPI" \ %(_databasename, _computername) import System conn = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("ADODB.Connection")) connstr = constr #"driver={SQL Server};Server=localhost;Database=mydatabase;Initial Catalog=mydatabase;Trusted_Connection=True;" conn.ConnectionString = connstr conn.Open() operation = "INSERT INTO Table_1 (Test1) VALUES (?)" b = buffer('\x02\x03\x04\x05') print 'b=',repr(b) cmd = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("ADODB.Command")) cmd.ActiveConnection=conn cmd.CommandText=operation cmd.CommandType=1 #adCmdText cmd.Parameters.Refresh() p = cmd.Parameters.Item[0] p.AppendChunk(b) # this is the error line ra = System.Reference[int]() rs = cmd.Execute(ra) count = ra.Value print 'Returned rowcount=',count </code> -- Vernon On Mon, Aug 3, 2009 at 5:33 PM, Dino Viehland <di...@microsoft.com> wrote: > Ok, I’ve finally got SQL server setup in a reasonable state where I can > try and repro this. This is what I’m trying to do. I have a database > called “mydatabase” which contains a table “Table_1” which contains 1 column > of type binary(4). I then attempt to do: > > > > import System > > conn = > System.Activator.CreateInstance(System.Type.GetTypeFromProgID("ADODB.Connection")) > > connstr = "driver={SQL Server};Server=localhost;Database=mydatabase;Initial > Catalog=mydatabase;Trusted_Connection=True;" > > conn.ConnectionString = connstr > > conn.Open() > > > > rs = > System.Activator.CreateInstance(System.Type.GetTypeFromProgID("ADODB.RecordSet")) > > rs.Open("Table_2", conn, 1, 2, 2) # source, active connection, cursor type > (adOpenKeyset), lock type (adLockPessimistic), CommmandType (adCmdTable) > > rs.AddNew() > > b = System.Array[System.Byte]((2,3,4,5)) > > x = rs['Test1'] > > x.AppendChunk(b) > > > > which fails with: > > > > EnvironmentError: System.Runtime.InteropServices.COMException (0x800A0C93): > Operation is not allowed in this context. > > > > This is the same failure I get if I use Shri’s proposed work around. Do > you have any idea of what I’m doing wrong or any suggestions on how to tweak > this to get the correct simple repro? > > > > *From:* users-boun...@lists.ironpython.com [mailto: > users-boun...@lists.ironpython.com] *On Behalf Of *Vernon Cole > *Sent:* Thursday, July 23, 2009 10:11 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] [ANN]: IronPython 2.6 Beta 2 > > > > Guys: > Good work on the new release, and the 215 bug fixes. As usual, as soon as > the new beta was announced I downloaded and tested it. > > Somehow I got the idea that the adodbapi test had been included in the > IronPython test suite. Did you only include the tests that already pass? > Issue 18222 is still unfixed -- so adodbapi still fails, and you still > cannot pass a read-only buffer as a COM parameter. > > I realize that no one has voted up this rather obscure bug. Perhaps if it > were titled "fully support DB API 2.0 compliant database access using ADO" > it would have gotten more votes. Nevertheless, this issue has been > outstanding for 11 months, and is the only remaining failure in adodbapi for > versions 2.3 thru 3.1 of python. Please try to get to it before 2.6 final. > > Please !!!??? > -- > Vernon Cole > > P.S. -- I plan to make a version of adodbapi which uses real ADO.NET, > rather than ADO via COM, but I want the current version to be solid before I > start mucking it up. > > _______________________________________________ > Users mailing list > 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