Professional Web Applications Themes

PostgreSQL Connection - ASP Database

Hi, I am trying to connect to a PostgreSQL database using asp. The code is as follows: <% dim rec1 dim strsearch dim strConnect strConnect="DRIVER={PostgreSQL};SERVER=localhost;D ATABASE=SIC;UID=sa;PWD=**********;Socket=4096" set rec1=server.createobject("adodb.recordset") strsearch = "SELECT SIC, Description FROM tblSIC" rec1.open strsearch,strconnect,adopenforwardonly,adlockreado nly response.write "<table><tr><td width=120><b>SIC</b></td><tdwidth=600><b>Description</b></td></tr>" while not rec1.eof response.write "<tr>" Response.Write "<td align=center>" & rec1("SIC") & "</td>" Response.Write "<td align=center>" & rec1("Description") & "</td>" Response.Write "</tr>" x = x + 1 rec1.movenext wend Response.Write "<tr><td colspan=4 align=left><br>" if x = 0 then Response.Write "No records were found" elseif x = 1 then Response.Write x & " record found" else Response.Write x & " records ...

  1. #1

    Default PostgreSQL Connection

    Hi,

    I am trying to connect to a PostgreSQL database using asp. The code is as
    follows:

    <%
    dim rec1
    dim strsearch
    dim strConnect

    strConnect="DRIVER={PostgreSQL};SERVER=localhost;D ATABASE=SIC;UID=sa;PWD=**********;Socket=4096" set rec1=server.createobject("adodb.recordset") strsearch = "SELECT SIC, Description FROM tblSIC" rec1.open strsearch,strconnect,adopenforwardonly,adlockreado nly response.write "<table><tr><td width=120><b>SIC</b></td><tdwidth=600><b>Description</b></td></tr>" while not rec1.eof response.write "<tr>" Response.Write "<td align=center>" & rec1("SIC") & "</td>" Response.Write "<td align=center>" & rec1("Description") & "</td>" Response.Write "</tr>" x = x + 1 rec1.movenext wend Response.Write "<tr><td colspan=4 align=left><br>" if x = 0 then Response.Write "No records were found" elseif x = 1 then Response.Write x & " record found" else Response.Write x & " records found" end if Response.Write "</td></tr></table>" rec1.close set rec1=nothing%>When I open the page I get the following error message.Microsoft OLE DB Provider for ODBC Drivers error '80004005'ERROR: relation "tblsic" does not exist/dev.asp, line 20I have checked everything out and all seems correct. The connection stringworks fine in a UDL file but it doesn't seem to work in asp. I can evencreate a dsn and export data from access to tblSIC with no problems. A pointto note is that somehow the asp code is looking for tblsic instead oftblSIC.Has anybody else got any experience of connecting to PostgreSQL and if socould they supply any pointers in trying to resolve this issue.RegardsPaul

    Paul Guest

  2. #2

    Default Re: PostgreSQL Connection

    Sorry about the formatting, not sure what happened.

    "Paul" <co.uk> wrote in message
    news:7p%9d.5737$news.blueyonder.co.uk... 


    Paul Guest

  3. #3

    Default Re: PostgreSQL Connection

    Paul wrote: 

    I am not familiar with PostgreSQL, but i do have a couple comments. 

    Is there a native OLEDB provider for PostgreSQL that you could try instead
    of ODBC? If so, I would try that first.
     

    You should not use your system administration account for your applications.
     

    The connection string does not appear to be the problem. You aren't getting
    a connection faliure are you? You're getting an error after the connection
    has been established. Does PostgreSQLhave any database mangement tools to
    allow you to view connections or trace commands sent to it? If so, I would
    use them to determine what is going on.
     

    Most databases I've worked with are case-insensitive. Is
    PostgreSQLdifferent?

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  4. #4

    Default Re: PostgreSQL Connection


    "Bob Barrows [MVP]" <SPAMcom> wrote in message
    news:phx.gbl... 
    >
    > I am not familiar with PostgreSQL, but i do have a couple comments. 
    >
    > Is there a native OLEDB provider for PostgreSQL that you could try instead
    > of ODBC? If so, I would try that first.

    >
    > You should not use your system administration account for your
    > applications.

    >
    > The connection string does not appear to be the problem. You aren't
    > getting a connection faliure are you? You're getting an error after the
    > connection has been established. Does PostgreSQLhave any database
    > mangement tools to allow you to view connections or trace commands sent to
    > it? If so, I would use them to determine what is going on.

    >
    > Most databases I've worked with are case-insensitive. Is
    > PostgreSQLdifferent?
    >
    > Bob Barrows
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >[/ref]

    Thanks for the pointers, I did manage to find an OLEDB driver and it
    connected OK although it is very slow. The drivers are open source
    development ones so I may have to look at using another DB platform.

    The sa account is not a true sa account. The default sy admin account for
    PostgreSQL is actually called postgres. I just created the sa account for
    that specific database.

    Thnaks for your help.

    Paul


    Paul Guest

Similar Threads

  1. #40544 [NEW]: PostgreSQL connection hangs after die()
    By kees at tweakers dot net in forum PHP Bugs
    Replies: 9
    Last Post: April 5th, 07:48 AM
  2. About PostgreSQL 8.0
    By Jarkko Elfving in forum PostgreSQL / PGSQL
    Replies: 2
    Last Post: January 22nd, 11:48 PM
  3. PostgreSQL v7.3.6
    By Jason.Davey in forum PostgreSQL / PGSQL
    Replies: 1
    Last Post: January 15th, 03:07 PM
  4. MS-SQL to PostgreSQL
    By Craig Bryden in forum PostgreSQL / PGSQL
    Replies: 2
    Last Post: January 8th, 01:53 AM
  5. PHP POSTGRESQL AND WML
    By Haydo Hassan in forum PHP Development
    Replies: 0
    Last Post: July 21st, 01:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139