You are using ADO to access SQL using an ODBC bridge, �is this what you
really want? You may access SQL Server without the ODBC bridge.

"Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User
Id=sa;Password=asdasd;"

versus

"Driver={SQL Server};Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd;"

[from www.connectrionstrings.com]

It is probably faster, although I have no empirical experience.

El jue, 03-03-2005 a las 11:22 -0500, Chris Curvey escribi�:
> I'm trying to get to an MS-SQL datbase via the win32com.client library 
> and the ADO library, but I seem to lose the context of the connection 
> whenever I execute a statement.  For example, the first "assert" below 
> is OK, but the second one is not.  I'm also losing the value of @@identity.
> 
> Is this a known issue?  I was hoping for a DB-API 2.0 interface to 
> MS-SQL, but I can't get my clients to pay for an mxODBC license.
> 
> import unittest
> from win32com.client import Dispatch
> 
> class TransactionTest(unittest.TestCase):
>     def testConnection(self):
>       conn = Dispatch('ADODB.Connection')
>       conn.Open("Driver={SQL
> Server};Server=mxdev;UID=chris_dev;PWD=chris;DATABASE=tempdb")
> 
>       # start a transaction 
>       conn.execute("begin tran")
> 
>       result = conn.execute("select @@trancount")
> 
>       while not result.EOF:
>           # this test passes
>           assert result.Fields.Item(0).Value == 1
>           result.MoveNext()
> 
>       result = conn.execute("select @@trancount")
>       while not result.EOF:
>           #this test fails
>           assert result.Fields.Item(0).Value == 1
>           result.MoveNext()
> 
> 
> ########################################################################
> if __name__ == "__main__":
>     unittest.main()
> 
> 
> _______________________________________________
> DB-SIG maillist  -  [email protected]
> http://mail.python.org/mailman/listinfo/db-sig

_______________________________________________
DB-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to