permission denied for relation

permission denied for relation

Postby skarosg3 » Tue 18 Feb 2014 10:01

Hi all,
I have been trying to get a Visual basic connection to my postgres DB for days, till i finaly came acros your site. it seems to be working like a charm. At least it seems to be connected to the DB.

I try to run a select command, as seen on your documentation

Code: Select all
Dim myConn As PgSqlConnection = New PgSqlConnection()
        myConn.ConnectionString = "User Id=myId;Password=Password;Host=192.168.1.250;Port=5432;Unicode=true;"
        myConn.Open()
        Dim command As PgSqlCommand = myConn.CreateCommand()
        command.CommandText = "select col from table"
Using readers As PgSqlDataReader = command.ExecuteReader()
                While readers.Read()
                For i As Integer = 0 To readers.FieldCount - 1
                    TextBoxA.Text = readers.GetValue(i).ToString() & vbNewLine
                Next
            End While
        End Using
        myConn.Close()

and i am getting an error on
readers As PgSqlDataReader = command.ExecuteReader()
The error is
permission denied for relation table


The postgres isntallation is on a lan computer, and i think i did everything ok. To be honest its the first postgres lan installation i did, but i assume everything is set up.

Do you have any idea what might be the problem?
skarosg3
 
Posts: 7
Joined: Tue 18 Feb 2014 09:53

Re: permission denied for relation

Postby Pinturiccio » Thu 20 Feb 2014 12:31

The exception "permission denied for relation table" is a PostgreSQL exception. This exception can be reproduced with pgAdmin too. This exception means that the 'myId' user does not have priviledges for performing SELECT from the table 'table'.

If you want to perform the query:
Code: Select all
select col from table

You need to grant the required privileges to the 'myId' user. For more information, please refer to http://www.postgresql.org/docs/9.0/static/sql-grant.html
Pinturiccio
Devart Team
 
Posts: 2021
Joined: Wed 02 Nov 2011 09:44


Return to dotConnect for PostgreSQL