Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to define query parameter for postgresql #102

Closed
hakancunier opened this issue Jul 21, 2019 · 7 comments
Closed

Impossible to define query parameter for postgresql #102

hakancunier opened this issue Jul 21, 2019 · 7 comments

Comments

@hakancunier
Copy link

hakancunier commented Jul 21, 2019

I want to create a datasource using postgresql connection in FastReport Desinger Community Edition. I write sql as;

select * from myusers where id=$1

and in the next screen create a parameter and didnt change the name as the docs stated, But i got an error saying "no parameters".

Then i named parameter as paramid then modified the sql as;
select * from myusers where id=@paramid
select * from myusers where id=@{paramid}
select * from myusers where id=$paramid
select * from myusers where id=${paramid}
select * from myusers where id=:paramid
select * from myusers where id=:{paramid}

all of sqls raised errors.

Is it really possible to do that?

@8VAid8
Copy link
Contributor

8VAid8 commented Jul 22, 2019

Hello!
I've checked parameters in Npgsql connection. You should use it like here:

select * from public."Users" where "Users"."Name"= @Name

And create parameter next.

The full example:

<?xml version="1.0" encoding="utf-8"?>
<Report ScriptLanguage="CSharp" ReportInfo.Created="07/22/2019 17:15:27" ReportInfo.Modified="07/22/2019 17:34:34" ReportInfo.CreatorVersion="2019.3.0.0">
  <Dictionary>
    <PostgresDataConnection Name="Connection" ConnectionString="your con">
      <TableDataSource Name="public_Users" DataType="System.Int32" Enabled="true" TableName="public.&quot;Users&quot;">
        <Column Name="id" DataType="System.Int32"/>
        <Column Name="Name" DataType="System.String"/>
      </TableDataSource>
      <TableDataSource Name="Table" DataType="System.Int32" Enabled="true" SelectCommand="select * from public.&quot;Users&quot; where &quot;Users&quot;.&quot;Name&quot;= @Name">
        <Column Name="id" DataType="System.Int32"/>
        <Column Name="Name" DataType="System.String"/>
        <CommandParameter Name="Name" DataType="19" Expression="[Name]" DefaultValue="Ivan"/>
      </TableDataSource>
    </PostgresDataConnection>
    <Parameter Name="Name" DataType="System.String" Expression="&quot;Ivan&quot;"/>
  </Dictionary>
  <ReportPage Name="Page1" Watermark.Font="Arial, 60pt">
    <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8"/>
    <PageHeaderBand Name="PageHeader1" Top="41.8" Width="718.2" Height="28.35">
      <TextObject Name="Text2" Left="85.05" Width="94.5" Height="18.9" Text="id" Font="Arial, 10pt"/>
      <TextObject Name="Text4" Left="283.5" Width="94.5" Height="18.9" Text="Name" Font="Arial, 10pt"/>
    </PageHeaderBand>
    <DataBand Name="Data1" Top="74.15" Width="718.2" Height="75.6" DataSource="Table">
      <TextObject Name="Text1" Left="85.05" Top="28.35" Width="94.5" Height="18.9" Text="[Table.id]" Font="Arial, 10pt"/>
      <TextObject Name="Text3" Left="283.5" Top="28.35" Width="94.5" Height="18.9" Text="[Table.Name]" Font="Arial, 10pt"/>
    </DataBand>
    <PageFooterBand Name="PageFooter1" Top="153.75" Width="718.2" Height="18.9"/>
  </ReportPage>
</Report>

@hakancunier
Copy link
Author

hakancunier commented Jul 24, 2019

Unfortunately doesnt worked. throws "input string was not in a correct format"

Here is my xml :
<Report ScriptLanguage="CSharp" ReportInfo.Created="07/25/2019 00:35:52" ReportInfo.Modified="07/25/2019 00:40:34" ReportInfo.CreatorVersion="2019.3.0.0"> <Dictionary> <PostgresDataConnection Name="Connection" ConnectionString="my con"> <TableDataSource Name="Table" DataType="System.Int32" Enabled="true" SelectCommand="select * from public.&quot;s_kullanici&quot; where &quot;s_kullanici&quot;.&quot;id&quot;=@prm"> <CommandParameter Name="prm" DataType="1"/> </TableDataSource> </PostgresDataConnection> </Dictionary> <ReportPage Name="Page1" Watermark.Font="Arial, 60pt"> <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8"/> <PageHeaderBand Name="PageHeader1" Top="40.47" Width="718.2" Height="28.35"/> <DataBand Name="Data1" Top="71.48" Width="718.2" Height="75.6"/> <PageFooterBand Name="PageFooter1" Top="149.75" Width="718.2" Height="18.9"/> </ReportPage> </Report>

@hakancunier
Copy link
Author

Using integer or bigint parameter datatype causes this problem. In my case the id field is mapped to a long property. If i select text as parameter datatype exception says id is bigint. If i select bigint throws "input string was not in a correct format"

@mehmetalageyik
Copy link

Same issue here

@8VAid8
Copy link
Contributor

8VAid8 commented Aug 13, 2019

Try to set up default value of the query parameter and add reference to a report parameter.
image

Unfortunately doesnt worked. throws "input string was not in a correct format"

Here is my xml :
<Report ScriptLanguage="CSharp" ReportInfo.Created="07/25/2019 00:35:52" ReportInfo.Modified="07/25/2019 00:40:34" ReportInfo.CreatorVersion="2019.3.0.0"> <Dictionary> <PostgresDataConnection Name="Connection" ConnectionString="my con"> <TableDataSource Name="Table" DataType="System.Int32" Enabled="true" SelectCommand="select * from public.&quot;s_kullanici&quot; where &quot;s_kullanici&quot;.&quot;id&quot;=@prm"> <CommandParameter Name="prm" DataType="1"/> </TableDataSource> </PostgresDataConnection> </Dictionary> <ReportPage Name="Page1" Watermark.Font="Arial, 60pt"> <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8"/> <PageHeaderBand Name="PageHeader1" Top="40.47" Width="718.2" Height="28.35"/> <DataBand Name="Data1" Top="71.48" Width="718.2" Height="75.6"/> <PageFooterBand Name="PageFooter1" Top="149.75" Width="718.2" Height="18.9"/> </ReportPage> </Report>

@8VAid8
Copy link
Contributor

8VAid8 commented Aug 13, 2019

Same issue here

Try the same solution, please

@hakancunier
Copy link
Author

Try to set up default value of the query parameter and add reference to a report parameter.
image

Unfortunately doesnt worked. throws "input string was not in a correct format"
Here is my xml :
<Report ScriptLanguage="CSharp" ReportInfo.Created="07/25/2019 00:35:52" ReportInfo.Modified="07/25/2019 00:40:34" ReportInfo.CreatorVersion="2019.3.0.0"> <Dictionary> <PostgresDataConnection Name="Connection" ConnectionString="my con"> <TableDataSource Name="Table" DataType="System.Int32" Enabled="true" SelectCommand="select * from public.&quot;s_kullanici&quot; where &quot;s_kullanici&quot;.&quot;id&quot;=@prm"> <CommandParameter Name="prm" DataType="1"/> </TableDataSource> </PostgresDataConnection> </Dictionary> <ReportPage Name="Page1" Watermark.Font="Arial, 60pt"> <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8"/> <PageHeaderBand Name="PageHeader1" Top="40.47" Width="718.2" Height="28.35"/> <DataBand Name="Data1" Top="71.48" Width="718.2" Height="75.6"/> <PageFooterBand Name="PageFooter1" Top="149.75" Width="718.2" Height="18.9"/> </ReportPage> </Report>

Yes it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants