Page 1 of 1

PgSqlCommandBuilder - How to exclude database name?

Posted: Mon 11 Dec 2006 11:15
by hmuscroft
Hi,

I have a database called "Sample Database". MyConnectionStr is as follows :-

Code: Select all

User Id=user;Password=passwd;Host=localhost;Port=5432;Database="Sample Database";Unicode=True;Schema=public;
There is a simple table called "layout" in the "public" schema defined as follows :-

Code: Select all

CREATE TABLE public.layout (
  id int8 NOT NULL,
  section varchar(30) NOT NULL,
  name varchar(120) NOT NULL,
  staff_id int8,
  data bytea,
  CONSTRAINT layout_pkey PRIMARY KEY(id)
)
WITHOUT OIDS;
If I do this :-

Code: Select all

PgSqlDataAdapter adap = new PgSqlDataAdapter("select * from layout", MyConnectionStr);
PgSqlCommandBuilder cb = new PgSqlCommandBuilder(adap);
Console.WriteLine(cb.GetUpdateCommand().CommandText);
The output is :-

UPDATE Sample Database.public.layout SET updatedby = :p1

Obviously that fails!!! How do I get PgSqlCommandBuilder to exclude the database name?

Thanks,

Hedley

Posted: Mon 11 Dec 2006 13:08
by Alexey
Try to set

Code: Select all

            cb.Quoted = true;

Posted: Tue 12 Dec 2006 12:24
by hmuscroft
Yes that works - thanks. :D

Posted: Tue 12 Dec 2006 13:13
by Alexey
You are welcome.