Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set a SQLQUERYSTRING to a SUBREPORT using ASP

Status
Not open for further replies.

arturrc

Programmer
Dec 28, 2000
6
BR
I'm using Crystal 8 in an IIS server with ASP pages.

I'm trying to call a report with subreport with a common field as link. I can't pass the SQLQueryString to the Subreport. My code is this:
<%
'on error resume next

reportname = &quot;oc2.rpt&quot;

%>

<!-- #include file=&quot;rpt_ini.asp&quot; -->

<%

sqltxt = &quot;&quot;
sqltxt = sqltxt & &quot;SELECT&quot;
sqltxt = sqltxt & &quot; ordem_compra.num_oc, ordem_compra.data_oc,&quot;
sqltxt = sqltxt & &quot; ordem_compra.cod_cr, ordem_compra.cod_forn,&quot;
sqltxt = sqltxt & &quot; ordem_compra.data_rec_mat, ordem_compra.transp_oc,&quot;
sqltxt = sqltxt & &quot; ordem_compra.texto_cond_pgto, ordem_compra.texto_obs1,&quot;
sqltxt = sqltxt & &quot; ordem_compra.texto_obs2, ordem_compra.texto_obs3,&quot;
sqltxt = sqltxt & &quot; ordem_compra.texto_obs4, ordem_compra.texto_obs5,&quot;
sqltxt = sqltxt & &quot; ordem_compra.texto_obs6, ordem_compra.texto_obs7,&quot;
sqltxt = sqltxt & &quot; ordem_compra.texto_obs8, ordem_compra.texto_obs9,&quot;
sqltxt = sqltxt & &quot; ordem_compra.texto_obs10, ordem_compra.texto_obs11,&quot;
sqltxt = sqltxt & &quot; ordem_compra.texto_obs12, ordem_compra.texto_obs13,&quot;
sqltxt = sqltxt & &quot; ordem_compra.texto_obs14, ordem_compra.texto_obs15,&quot;
sqltxt = sqltxt & &quot; empresa.nome_empresa, empresa.num_cgc_empresa,&quot;
sqltxt = sqltxt & &quot; empresa.ins_est_empresa, empresa.end_empresa,&quot;
sqltxt = sqltxt & &quot; empresa.cidade_empresa, empresa.uf_empresa,&quot;
sqltxt = sqltxt & &quot; empresa.cep_empresa, empresa.bairro_empresa,&quot;
sqltxt = sqltxt & &quot; empresa.tel_empresa, empresa.telex_empresa,&quot;
sqltxt = sqltxt & &quot; empresa.fax_empresa, fornecedor.cod_forn,&quot;
sqltxt = sqltxt & &quot; fornecedor.raz_soc_forn, fornecedor.cpfcgc_forn,&quot;
sqltxt = sqltxt & &quot; fornecedor.inc_est_forn, fornecedor.end_forn,&quot;
sqltxt = sqltxt & &quot; fornecedor.bairro_forn, fornecedor.cep_forn,&quot;
sqltxt = sqltxt & &quot; fornecedor.cidade_forn, fornecedor.uf_forn,&quot;
sqltxt = sqltxt & &quot; fornecedor.telefone_forn, fornecedor.telex_forn,&quot;
sqltxt = sqltxt & &quot; fornecedor.fax_forn, fornecedor.contato_forn,&quot;
sqltxt = sqltxt & &quot; centresp.cod_cr, centresp.desc_cr,&quot;
sqltxt = sqltxt & &quot; centresp.local_cr, centresp.end_cr,&quot;
sqltxt = sqltxt & &quot; centresp.bairro_cr, centresp.tel_cr&quot;

SELECT_Str = sqltxt

sqltxt = &quot;&quot;
sqltxt = &quot; FROM&quot;
sqltxt = sqltxt & &quot; ordem_compra, empresa,&quot;
sqltxt = sqltxt & &quot; centresp, fornecedor&quot;

FROM_Str = sqltxt

sqltxt = &quot;&quot;
sqltxt = &quot; WHERE&quot;
sqltxt = sqltxt & &quot; empresa.cod_empresa = centresp.cod_empresa&quot;
sqltxt = sqltxt & &quot; AND empresa.cod_empresa = fornecedor.cod_empresa&quot;
sqltxt = sqltxt & &quot; AND ordem_compra.cod_cr = centresp.cod_cr&quot;
sqltxt = sqltxt & &quot; AND ordem_compra.cod_forn = fornecedor.cod_forn&quot;
sqltxt = sqltxt & &quot; AND ordem_compra.num_oc = &quot; & Request.querystring(&quot;lknumoc&quot;)

WHERE_Str = sqltxt

NewSQLQueryString = SELECT_Str & CHR(13)& FROM_Str & CHR(13) & WHERE_Str & CHR(10)& CHR(13)

session(&quot;oRpt&quot;).DiscardSavedData

set crtable = session(&quot;oRpt&quot;).Database.Tables.Item(1)
crtable.SetLogonInfo &quot;Banco de Producao&quot;, &quot;db_prod&quot;,session(&quot;gs_login&quot;),session(&quot;gs_senha&quot;)
set crtable = session(&quot;oRpt&quot;).Database.Tables.Item(2)
crtable.SetLogonInfo &quot;Banco de Producao&quot;, &quot;db_prod&quot;,session(&quot;gs_login&quot;),session(&quot;gs_senha&quot;)
set crtable = session(&quot;oRpt&quot;).Database.Tables.Item(3)
crtable.SetLogonInfo &quot;Banco de Producao&quot;, &quot;db_prod&quot;,session(&quot;gs_login&quot;),session(&quot;gs_senha&quot;)
set crtable = session(&quot;oRpt&quot;).Database.Tables.Item(4)
crtable.SetLogonInfo &quot;Banco de Producao&quot;, &quot;db_prod&quot;,session(&quot;gs_login&quot;),session(&quot;gs_senha&quot;)

session(&quot;oRpt&quot;).SQLQueryString = cstr(NewSQLQueryString)

Set CRSubreports = session(&quot;oRpt&quot;).OpenSubreport(&quot;rptItemOC&quot;)

sqltxt = &quot;&quot;
sqltxt = sqltxt & &quot;SELECT&quot;
sqltxt = sqltxt & &quot; item_oc.num_oc, item_oc.num_item_oc,&quot;
sqltxt = sqltxt & &quot; item_oc.qte_item_oc, item_oc.valor_unit_ioc,&quot;
sqltxt = sqltxt & &quot; item_oc.desconto_ioc, item_oc.ipi_ioc,&quot;
sqltxt = sqltxt & &quot; item_oc.emb_ioc, item_oc.outros_ioc,&quot;
sqltxt = sqltxt & &quot; item_oc.frete_ioc, material.unid_material,&quot;
sqltxt = sqltxt & &quot; material.desc_material&quot;
sqltxt = sqltxt & &quot; FROM&quot;
sqltxt = sqltxt & &quot; db_prod:admdados.item_oc item_oc, db_prod:admdados.material material&quot;
sqltxt = sqltxt & &quot; WHERE&quot;
sqltxt = sqltxt & &quot; item_oc.cod_material = material.cod_material&quot;
sqltxt = sqltxt & &quot; AND item_oc.num_oc = &quot; & request.querystring(&quot;lknumoc&quot;)
sqltxt = sqltxt & &quot; ORDER BY&quot;
sqltxt = sqltxt & &quot; item_oc.num_oc ASC, item_oc.num_item_oc ASC&quot; & CHR(10)& CHR(13)

set CRSubTable = CRSubreports.Database.Tables.Item(1)
CRSubTable.SetLogonInfo &quot;Banco de Producao&quot;, &quot;db_prod&quot;,session(&quot;gs_login&quot;),session(&quot;gs_senha&quot;)
set CRSubTable = CRSubreports.Database.Tables.Item(2)
CRSubTable.SetLogonInfo &quot;Banco de Producao&quot;, &quot;db_prod&quot;,session(&quot;gs_login&quot;),session(&quot;gs_senha&quot;)

CRSubreports.SQLQueryString = cstr(sqltxt)
'the line above is my problem

%>

<!-- #include file=&quot;rpt_ini1.asp&quot; -->

<!-- #include file=&quot;SmartViewerActiveX.asp&quot; -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top