passing sql to the report

Hi,

I designed the report, datasource is: Datasource->Connection->Table,Datasource->Connection->Table1, Datasource->Connection->Table2.

I cant pass the parameter, because selected command is a openquery from MSSQL to Oracle linked server (And by default you can't pass parameter in openquery.

So I'd like to change 3 sql tables directly from c# application


I don't want to create new data sources form c#, only change SQL command of existing one.


This is part of the code:

string appPath = System.Windows.Forms.Application.StartupPath;

string pathtoreport = appPath + "\\rep.frx";

 Report rp = new Report();          

  rp.Load(pathtoreport);

  TableDataSource t = rp.GetDataSource("Connection") as TableDataSource;

            t.SelectCommand = "select * from openquery(LinkedServer,'

select est.t$pdno, est.t$opno, est.t$pono, est.t$sitm , it.t$dsca, est.t$revi, est.t$cwar, est.t$bfls, op.t$cwoc, op.t$tano, op.t$rsdt,est.t$ques ,

case when it.t$seri = 1 then ''Yes'' else '' '' end as t$seri

, it.t$csig

from erpln6c.tticst001215 est

inner join erpln6c.ttcibd001215 it on it.t$item = est.t$sitm

inner join erpln6c.ttisfc010215 op on (op.t$pdno = est.t$pdno and op.t$opno = est.t$opno)

where est.t$pdno =''XXXXXXX''

order by est.t$opno, est.t$pono

')";


But this doesn't work.... my favorite error: object reference not set to an instance of an object.


What I'm doing wrong ?

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.