ADO/ODBC call via Python/IIS

Steve Holden sholden at holdenweb.com
Fri Feb 2 16:49:32 EST 2001


"Bill Seitz" <fluxent at yahoo.com> wrote in message
news:95f558$jgl$1 at nnrp1.deja.com...
> Architecture: ASP page using <%@ LANGUAGE = Python%>, calling Python
> class which calls ADO to pass SQL command via ODBC driver to MsSQL db.
> (Everything running on Win2K.) MsSQL configured to authenticate against
> ActiveDirectory only. Sysadmin created userID 'pyasp'. I created MsSQL
> login and assigned user rights in the appropriate db. I created an ODBC
> source named 'pyasp', assigned the current db as the default.
>
> Here is the class that does the work (in file 'aAdoBiz.py')
> class aConnect:
>     def __init__(self):
>         import win32com.client
>         adoConn = win32com.client.Dispatch('ADODB.Connection')
>         adoConn.Open('pyasp')
>         (adoRS, success) = adoConn.Execute('Select * from RateUnits')
>         adoRS.MoveFirst()
>         adoRS.MoveNext()
>         self.fieldName = adoRS.Fields("Name").Value
>
> When I call this code interactively, I get the right result:
> >>> import aAdoBiz
> >>> z=aAdoBiz.aConnect()
> >>> z.fieldName.encode()
> 'Days           '
>
> But then I have the same idea implemented in an ASP page:
> <%
> import aAdoBiz
> x = aAdoBiz.aConnect()
> out = x.fieldName.encode()
> %>
> <%= out %>
>
> (A very similar ASP page, calling a simple stub class with no ODBC
> activity, works fine.)
>
> When I call this ASP page, I get an error to the browser...
> HTTP 500.100 - Internal Server Error - ASP error
> Error Type:
> Python ActiveX Scripting Engine (0x80020009)
> Traceback (innermost last): File "<Script Block >", line 3, in ? x =
> aAdoBiz.aConnect() File "aAdoBiz.py", line 7, in __init__ adoConn.Open
> ('pyasp') File "c:\python20\win32com\gen_py\00000206-0000-0010-8000-
> 00AA006D2EA4x0x2x6.py", line 1833, in Open return self._ApplyTypes_
> (0xa, 1, (24, 32), ((8, 49), (8, 49), (8, 49), (3, 49)), 'Open',
> None,ConnectionString, UserID, Password, Options) File "c:\python20
> \win32com\client\__init__.py", line 334, in _ApplyTypes_ return
> self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0,
> wFlags, retType, argTypes) + args), user, resultCLSID) COM Error:
> [Microsoft][ODBC Driver Manager] Data source name not found and no
> default driver specified
>
> What is happening here? Why the error when called from IIS, but not
> when run interactively?
>
Is it possobile pyasp is a user DSN, when ASP expects systems DSNs?

regards
 Steve





More information about the Python-list mailing list