(Newbie-ish) pgSqlCommand seems to be case insensitive

(Newbie-ish) pgSqlCommand seems to be case insensitive

Postby kerrywales » Wed 19 May 2010 09:51

I am writing an applet to restore data to a db using pgSqlDump.

I am presuming that the restore method will not overwrite the tables or clear them down before restoring (at least not read anyhing to let me do that yet) so I though a simple drop db and recreate will do the job.

The code in use is:
Devart.Data.PostgreSql.PgSqlCommand command1 = new Devart.Data.PostgreSql.PgSqlCommand
("DROP DATABASE IF EXISTS " + dbName + ";", myConnection.getConnection());
Devart.Data.PostgreSql.PgSqlCommand command2 = new Devart.Data.PostgreSql.PgSqlCommand
("CREATE DATABASE " + dbName + " ENCODING 'WIN1252' TEMPLATE template0;", myConnection.getConnection());
try
{
command1.ExecuteNonQuery();
}
catch (Exception ex) { MessageBox.Show(ex.Message); };
try
{
command2.ExecuteNonQuery();
}
catch (Exception ex) { MessageBox.Show(ex.Message); };


dbName has the value NewTest

No errors the code. The code does execute BUT. My Db NewTest remains in the schema but a database newtest is created i.e. it ignores the case of the characters in the name of the db.

Is this a postgres issue or a devart issue?

Thank you :?:
kerrywales
 
Posts: 52
Joined: Tue 05 Jan 2010 12:26

Postby StanislavK » Wed 19 May 2010 16:59

By default, PostgreSQL servers are case-insensitive. To use case-sensitive string constants, please quote them:
Code: Select all
CREATE DATABASE "NewTest";
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby kerrywales » Wed 19 May 2010 20:39

Thank you. That is exactly the issue. And the solution.
kerrywales
 
Posts: 52
Joined: Tue 05 Jan 2010 12:26


Return to dotConnect for PostgreSQL