OleDb - As to use named parameters

Stimulsoft Reports.NET discussion
Post Reply
webermiranda
Posts: 3
Joined: Sun Apr 15, 2007 7:16 pm

OleDb - As to use named parameters

Post by webermiranda »

Hello!
I am evaluating the StimulReport.Net to use it in a Web application.
My reports possess parameters and I possess used pages to get these parameters of the user.

As my application must be able to use Oracle or SQL Server, I am using OleDb as connection with the Database.

I use StimulReport 2007 in Portuguese with Windows XP SP2

I need to use parameters in some consultations, where the same parameter is used more than a time in one same instruction SQL:
SELECT *
FROM SSEmpresa
WHERE (@pCodEmpresa = 0 OR EM_Codigo = @pCodEmpresa)


@pCodEmpresa is used some times in the SQL.
This is only one example. I have several other similar situations.

I am receiving the following message when trying to emit the report (Portuguese Br):
Não foi possível preparar instrução(ões)
É necessário declarar a variável escalar "@pCodEmpresa".

I tried to use the parameters with the character "?", but in this in case that it is necessary to inform value for parameter the same two times.

How I make to use parameters named with OleDb connection?

Thank you,

Weber Miranda.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

OleDb - As to use named parameters

Post by Edward »

webermiranda wrote:Hello!
I am evaluating the StimulReport.Net to use it in a Web application.
My reports possess parameters and I possess used pages to get these parameters of the user.

As my application must be able to use Oracle or SQL Server, I am using OleDb as connection with the Database.
Please note that unnamed parameters works usually with any Server and it is not depends on the version of the OleDb driver. But sometimes using of named parameters with OleDB connection is not possible. In that case you need to use special Database pack for your Server.

Oracle provider for the StimulReport.Net you can to download here:

http://stimulsoft.com/Downloads/OracleDatabase.zip

Also possible using a variable from the Dictionary as parameter:

Code: Select all

select Category from Categories where CategoryID = {myParameter} 
myParameter - it is the string type variable from the Dictionary.

Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

OleDb - As to use named parameters

Post by Edward »

Please note that unnamed parameters works usually with any Server and it is not depends on the version of the OleDb driver. But sometimes using of named parameters with OleDB connection is not possible.
Unnamed parameters allows to achieve the goal. But we cannot influence on processing of the named parameters, because ADO.Net processing this.

Thank you.
webermiranda
Posts: 3
Joined: Sun Apr 15, 2007 7:16 pm

OleDb - As to use named parameters

Post by webermiranda »

Thank, Edward.

Using variables of the dictionary as parameters it will be possible to make what necessary.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

OleDb - As to use named parameters

Post by Vital »

Yes, you can use expression in sql query. For example:

Code: Select all

select * from customers where id={variable}
but in this case you need be very careful with dates.

Thank you.
webermiranda
Posts: 3
Joined: Sun Apr 15, 2007 7:16 pm

OleDb - As to use named parameters

Post by webermiranda »

The dates will not be a problem in this in case that, therefore they are recorded in fields of the Integer type, in format YYYYMMDD.

Thank you!
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

OleDb - As to use named parameters

Post by Edward »

Thank you.
Post Reply