Page 1 of 1

The query syntax is not valid., near identifier 'SESSION

Posted: Wed 16 Dec 2009 19:54
by Wupaz
I do the same thing with Orace driver (MSFT) and it work perfectly !

Sample code

var command = model.Connection.CreateCommand();
command.Connection.Open();
var tns = model.Connection.BeginTransaction();

command.Connection = model.Connection;

command.CommandType = CommandType.Text;
command.CommandText = @"ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';";
command.Transaction = tns;
command.Parameters.Clear();

command.ExecuteNonQuery();

Posted: Thu 17 Dec 2009 16:35
by StanislavK
Please remove the semicolon from the CommandText, this will be

Code: Select all

command.CommandText = @"ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'";
dotConnect for Oracle doesn't parse OracleCommand.CommandText, thus the command with a semicolon is interpreted as a PL/SQL block and hence causes an error. If you do want to use a PL/SQL block, please use the OracleScript class.