Subject | Substring function not working? |
---|---|
Author | alexandermezhov |
Post date | 2013-02-28T18:15:23Z |
Hello!
I use FirebirdClient ADO.NET <http://ado.net/> Data Provider (v 3.0.2)
and try to execute query that look like this:
select * from "SomeTable" where substring("SomeColumn" from @p0 for 4) =
'SomeString'
where @p0 - query parameter. As a result, I get an exception:
FirebirdSql.Data.FirebirdClient.FbException (0x80004005): expression
evaluation not supported ---> expression evaluation not supported at
FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior
be havior) in
c:\Users\Jiri\Documents\devel\NETProvider\working\trunk\NETProvider\sour\
ce\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 554 at
FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader() in
c:\Users\Jiri\Documents\devel\NETProvider\working\trunk\NETProvider\sour\
ce\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 538
However if the parameter @p0 is replace by a constant value everything
works fine:
select * from "SomeTable" where substring("SomeColumn" from 1 for 4) =
'SomeString'
My code:
class Program
{
static void Main()
{
var connectionString = new FbConnectionStringBuilder
{
DataSource = "localhost",
Database =
Path.GetFullPath(@"..\..\..\Data\TestDatabase.fdb"),
ServerType =
FbServerType.Default,
UserID = "SYSDBA",
Password = "masterkey",
Charset = "UTF8",
}.ToString();
try
{
using (var connection = new FbConnection(connectionString))
{
using (var command = connection.CreateCommand())
{
command.CommandText = @"select * from ""TESTENTITY""
where substring(""NAME"" from @p0 for 4) = 'Item'";
command.Parameters.Add(new FbParameter("p0", 1));
connection.Open();
using (var reader = command.ExecuteReader()) // The
exception occurs here!
{
while (reader.Read())
{
Console.WriteLine("{0}", reader["NAME"]);
}
}
}
}
}
catch (Exception error)
{
Console.WriteLine(error);
}
Console.ReadLine();
}
}
You can download project here <http://goo.gl/VrqbV> .
Please tell me what I'm doing wrong?
[Non-text portions of this message have been removed]
I use FirebirdClient ADO.NET <http://ado.net/> Data Provider (v 3.0.2)
and try to execute query that look like this:
select * from "SomeTable" where substring("SomeColumn" from @p0 for 4) =
'SomeString'
where @p0 - query parameter. As a result, I get an exception:
FirebirdSql.Data.FirebirdClient.FbException (0x80004005): expression
evaluation not supported ---> expression evaluation not supported at
FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior
be havior) in
c:\Users\Jiri\Documents\devel\NETProvider\working\trunk\NETProvider\sour\
ce\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 554 at
FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader() in
c:\Users\Jiri\Documents\devel\NETProvider\working\trunk\NETProvider\sour\
ce\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 538
However if the parameter @p0 is replace by a constant value everything
works fine:
select * from "SomeTable" where substring("SomeColumn" from 1 for 4) =
'SomeString'
My code:
class Program
{
static void Main()
{
var connectionString = new FbConnectionStringBuilder
{
DataSource = "localhost",
Database =
Path.GetFullPath(@"..\..\..\Data\TestDatabase.fdb"),
ServerType =
FbServerType.Default,
UserID = "SYSDBA",
Password = "masterkey",
Charset = "UTF8",
}.ToString();
try
{
using (var connection = new FbConnection(connectionString))
{
using (var command = connection.CreateCommand())
{
command.CommandText = @"select * from ""TESTENTITY""
where substring(""NAME"" from @p0 for 4) = 'Item'";
command.Parameters.Add(new FbParameter("p0", 1));
connection.Open();
using (var reader = command.ExecuteReader()) // The
exception occurs here!
{
while (reader.Read())
{
Console.WriteLine("{0}", reader["NAME"]);
}
}
}
}
}
catch (Exception error)
{
Console.WriteLine(error);
}
Console.ReadLine();
}
}
You can download project here <http://goo.gl/VrqbV> .
Please tell me what I'm doing wrong?
[Non-text portions of this message have been removed]