dim adoConn dim adoRS dim counter set adoConn = Server.CreateObject("ADODB.Connection") set adoRS = Server.CreateObject("ADODB.Recordset") strConn = "Provider=PostgreSQL.1;Data Source=localhost;location=postgres;" & _ "User Id=login_role;password=login_role_password;" adoConn.Open strConn adoRS.ActiveConnection = adoConn if adoConn.errors.count = 0 then adoRS.Open "select * from phpbb.phpbb_users" while not adoRS.EOF response.write adoRS.fields(0).value adoRS.MoveNext wend else response.write "ERROR: Couldn't connect to database" end if
Probably the most interesting thing is the connectionstring where:
Localhost is the server
postgres is the database
login_role is ... the login role AKA username
and in the query phpbb is the schema.
To avoid access denied errors you'll have to grant proper rights to the phpbb schema to user login_role, like :
GRANT ALL privileges ON schema phpbb TO login_role;
No comments:
Post a Comment