Frustrated

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Spence2020
Posts: 2
Joined: Sun 07 Oct 2012 20:25

Frustrated

Post by Spence2020 » Sun 07 Oct 2012 20:40

Good Evening,

This is my first time working with databases from within VB.net (or any programming language). I have attempted to use the documentation on your site to get it working, but I can never get it to work by using the samples as examples.

I can connect to the database -- I used to be able to pull information from the database (somehow that is not longer working), but I can not figure out how to add and update new rows in to the Database.

With the documentation provided I am just not proficient enough to figure it out. Can I use other forms of documentation from other sites or will it not be accurate since I have to use dotConnect?

Thanks

Spence2020
Posts: 2
Joined: Sun 07 Oct 2012 20:25

Re: Frustrated

Post by Spence2020 » Mon 08 Oct 2012 01:42

It turns out I am not completed retarded.

The issue is that I used pgAdmin III's GUI to build the database and it has a habit of putting quotes around the column names. That coupled with the fact that I was using Mixed Case in column names led to me being unable to work with anything unless I used char(34) and jumped through hurdles.

Therefore I am now in the process of changing all my tables and columns to lowercase.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Frustrated

Post by Pinturiccio » Fri 12 Oct 2012 12:45

By default PostgreSQL uses lower case. So, if you have a query like "select * from Dept", PostgreSQL interprets this query as "select * from dept".
If you are using Mixed Case in table names or in column names, then these names should be quoted in the query. This concerns not only dotConnect for PostgreSQL, but pgAdmin III too. Let's consider the following example:

Use these scripts with pgAdmin III
DDL script:

Code: Select all

CREATE TABLE "Test_t"
(
  "ID" integer NOT NULL,
  "name" text,
  CONSTRAINT "Test_t_pkey" PRIMARY KEY ("ID")
);
ALTER TABLE "Test_t" OWNER TO postgres;
DML script:

Code: Select all

INSERT INTO "Test_t"("ID", name) VALUES (1, 'Hello');
As you can see, the column 'name' can be used without quotes. However, using quotes with "Test_t" and "ID" is necessary.

Visual Basic code for a simple select:

Code: Select all

Imports Devart.Data.PostgreSql

Module Module1

    Sub Main()
        Dim conn As PgSqlConnection = New PgSqlConnection("host=your host;port=your port;uid=postgres;pwd=your password;")
        conn.Open()
        Dim comm As PgSqlCommand = New PgSqlCommand("Select name from ""Test_t"" where ""ID""=1", conn)
        Console.WriteLine(comm.ExecuteScalar())
        conn.Close()
    End Sub

End Module
Spence2020 wrote:With the documentation provided I am just not proficient enough to figure it out.
Could you please tell us, what exactly you could not understand? How to establish a connection or how to create a query to a database? We will try to help you.

Please note, that dotConnect for PostgreSQL has samples located in the folder with dotConnect for PostgreSQL C:\Program Files (x86)\Devart\dotConnect\PostgreSQL\Samples or in 'Start Menu->All Programs->Devart dotConnect
for PostgreSQL->Samples'

Post Reply