X-Original-To: pgsql-odbc@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6AB5C476085 for ; Sun, 13 Apr 2003 17:53:58 -0400 (EDT) Received: from mta06bw.bigpond.com (mta06bw.bigpond.com [139.134.6.96]) by postgresql.org (Postfix) with ESMTP id E72EE47580B for ; Sun, 13 Apr 2003 17:53:55 -0400 (EDT) Received: from NBKDGARCIA ([144.135.24.72]) by mta06bw.bigpond.com (Netscape Messaging Server 4.15 mta06bw Jul 16 2002 22:47:55) with SMTP id HDAY6I00.1IT; Mon, 14 Apr 2003 07:54:18 +1000 Received: from 203.40.203.235 ([203.40.203.235]) by bwmam02.bigpond.com(MAM V3.3.2 11/17239606); 14 Apr 2003 07:54:09 From: "Daniel F Garcia" To: , Subject: Re: Connection to posgresql database works under windows scripting host but not IIS/ASP Date: Mon, 14 Apr 2003 07:54:07 +1000 Message-ID: <000e01c30207$3b786b40$31020b0a@corp.systems.ballsolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <20030411123844.91312.qmail@web13803.mail.yahoo.com> Importance: Normal X-Spam-Status: No, hits=-32.1 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,ORIGINAL_MESSAGE, QUOTED_EMAIL_TEXT,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/46 X-Sequence-Number: 2848 The problem still occurs after making the suggested changed. I'm pretty sure that the problem isn't with the connection script as a similar script works when I run it on the same box under windows scripting host. As you can see below, both script use the same connection string. Daniel. -----Original Message----- From: pgsql-odbc-owner@postgresql.org [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Chris Gamache Sent: Friday, 11 April 2003 10:39 PM To: Daniel F Garcia; pgsql-odbc@postgresql.org Subject: Re: [ODBC] Connection to posgresql database works under windows scripting host but not IIS/ASP First, to create a connection string, create a file with a udl extension. An easy way to do this is right-click and create a new text document, then rename it. Click on the icon and the universal data link applet will appear. Create a link to PostgreSQL. Close the applet, then open the document in notepad. You'll find a full-blown connection string pre-made for you. I usually remove the DSN reference and user DRIVER=3D{drivername} instead. You might have to add a PWD=3Dpassword in the extended properties too... I've found that if I pass "pointers" (if you can call a variant reference to another variant a pointer!) to recordsets and connection objects within functions I get unpredictable results (memory leaks, crashes, etc.). If you're going to use "conn" or "rs" outside your function you might be better off to declare the objects in the main scope of the script. "Option Explicit" is also a good idea. It helps by forcing you to declare all variables. Here's a revised function that should work for you (with conn and rs only within the scope of your script): Function nugget_forum(column) start_nugget column,"::Rumour Mill" 'Server.createobject is better suited to all COM+ 'references in ASP. I think this is your main problem... Set conn =3D Server.CreateObject("adodb.connection") ' Here's a plain connection string. modify to suit... connstr =3D "Provider=3DMSDASQL.1;" & _ "Persist Security Info=3DFalse;Extended " & _ "Properties=3D""DRIVER=3D{PostgreSQL+ (Beta)};" & _ "DATABASE=3Dwhatever;SERVER=3D10.11.2.5;PORT=3D5432;" & _ "UID=3Duid;PWD=3Dpwd;ReadOnly=3D0;Protocol=3D6.4;FakeOidIndex=3D0;" = & _ "ShowOidColumn=3D0;RowVersioning=3D0;ShowSystemTables=3D0;" & _ "ConnSettings=3D;Fetch=3D100;Socket=3D4096;UnknownSizes=3D0;" & _ "MaxVarcharSize=3D254;MaxLongVarcharSize=3D8190;Debug=3D0;" & _ "CommLog=3D0;Optimizer=3D1;Ksqo=3D1;UseDeclareFetch=3D0;" & _ "TextAsLongVarchar=3D1;UnknownsAsLongVarchar=3D0;" & _ "BoolsAsChar=3D1;Parse=3D0;CancelAsFreeStmt=3D0;" & _ "ExtraSysTablePrefixes=3Ddd_;;LFConversion=3D1;" & _ "UpdatableCursors=3D1;DisallowPremature=3D0;TrueIsMinus1=3D0;BI=3D0"= "" conn.Open connstr 'Set rs =3D server.CreateObject("adodb.recordset") 'querystr =3D "SELECT * FROM ib_forum_posts;" 'rs.open querystr, conn,3,3 Conn.close end_nugget(column)=20=20 end Function One more tip: concatenation (string & string & string) and rs.movenext will give you a huge performance hit. Consider using a complex postgresql query and rs.getstring if you're just outputting a table of data. If you HAVE to munch each row, use rs.getrows, which returns an array of the table. Much faster. CG --- Daniel F Garcia wrote: > Environment: > =3D=3D=3D=3D=3D=3D=3D=3D=3D > Windows 2000 server running IIS. This server is a domain controller.=20 > This server is runnning version 7.2.5 of the postgres odbc driver. > Debian Linux server running a postgres database >=20=20 > ASP script: > =3D=3D=3D=3D=3D=3D=3D=3D >=20=20 > Function nugget_forum(column) > start_nugget column,"::Rumour Mill" > Set conn =3D CreateObject("adodb.connection") > conn.ConnectionString =3D=20 > "DRIVER=3D{PostgreSQL};sERVER=3D10.11.2.5;port=3D5432;DATABASE=3Ddbname;U= ID=3Dui > d;PWD=3D > pwd;" > conn.Open=20 > 'Set rs =3D CreateObject("adodb.recordset") > 'querystr =3D "SELECT * FROM ib_forum_posts;" > 'rs.open querystr, conn,3,3 > Conn.close > end_nugget(column)=20=20 > end Function >=20=20 > script run under windows scripting host =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20=20 > When I run this script under windows scripting host I get a connection=20 > and am able to retrieve data. >=20=20 > Set conn =3D CreateObject("adodb.connection") conn.ConnectionString =3D > "DRIVER=3D{PostgreSQL};sERVER=3D10.11.2.5;port=3D5432;DATABASE=3Ddbname;UID= =3Duid;PWD=3D > pwd;" > conn.Open=20 > Set rs =3D CreateObject("adodb.recordset") > querystr =3D "SELECT * FROM ib_forum_posts;" > rs.open querystr, conn,3,3 > do while not rs.eof > wscript.echo rs.Fields(0).value & ":" & rs.Fields(1).value & ":" & > rs.Fields(12).value > rs.MoveNext=20=20=20=20 > loop > Conn.close >=20=20 > The error > =3D=3D=3D=3D=3D=3D=3D >=20=20 > When I run the script in an ASP I get the following error. >=20=20 > Microsoft OLE DB Provider for ODBC Drivers (0x80004005)=20 > [Microsoft][ODBC Driver Manager] Data source name not found and no=20 > default driver specified /intranet/default.asp, line 35 >=20 > Line 35 is the conn.open statement >=20=20 >=20=20 > I initally thought that this might be a permissions problem. I added=20 > IUSR_SRV-AMB-DB temporarily to the domain admin group and restarted=20 > IIS, but it didn't make a difference. >=20=20 > I'm at a loss. Can someone please help me. >=20=20 > Best Regards, >=20 > Daniel F Garcia. >=20 __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html