通过vs.net帮助在运行时更改Crystal Report sql查询。 [英] HELP on Changing Crystal Report sql query at run time via vs.net.

查看:63
本文介绍了通过vs.net帮助在运行时更改Crystal Report sql查询。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你的帮助!


我已经看到在vs.net(vb.net)中使用Crystal Reports的所有帖子

和在运行时更改SQL查询。当我试图在运行时将数据集

传入晶体报告时,报告仍然显示默认查询(来自Crystal Report中)的结果

。 br />

然后我尝试了XSD解决方案,您可以在其中定义数据集(数据库和Crystal报表的数据),并使用Crystal Report

这个。使用XSD解决方案的所有示例都使用一个表。我有四张桌子,当我填满我的数据集并将其传递给报告时,

报告显示为空白(即使数据集中有数据)。

男人,我希望有一个我可以更改的sqlquery属性!


我已经尝试了以下内容并且都带回了一个空白报告:


---------

strSQL''一个连接四个表并带回所有结果的查询

四个表


Dim da As SqlClient.SqlDataAdapter = New

SqlClient.SqlDataAdapter(strSQL,strConnectionString)


Attempt 1.

Dim ds As New System.data.DataSet

da.Fill(ds)

SomeCrystalReport.SetDataSource(ds)


尝试2.

Dim ds As New System.data.DataSet

da.Fill(ds," Table1" )

da.Fill(ds," Table2")

da.Fill(ds," Table3")

da.Fill (ds,Table4)

SomeCry stalReport.SetDataSource(ds)


尝试3.

Dim ds As New System.data.DataSet

da.Fill( ds," Table1")

da.Fill(ds," Table2")

da.Fill(ds," Table3")

da.Fill(ds," Table4")


Dim i As Integer = 0

虽然我< SomeCrystalReport.Database.Tables.Count

SomeCrystalReport.Database.Tables(i).SetDataSource(ds.Tables(i))

i = i + 1

结束时


尝试4.

Dim ds As New System.data.DataSet

da.Fill(ds ,表1)

da.Fill(ds," Table2")

da.Fill(ds," Table3")

da.Fill(ds," Table4")

SomeCrystalReport.Database.Tables(" Table1")。SetDat aSource(ds.Tables(" Table1")))


SomeCrystalReport.Database.Tables(" Table1")。SetDat aSource(ds.Tables(" Table2"))


SomeCrystalReport .Database.Tables(" Table1")。SetDat aSource(ds.Tables(" Table3"))

SomeCrystalReport.Database.Tables(" Table1")。SetDat aSource (ds.Tables(" Table4"))

尝试5.

Dim ds为新Some_XSD_dataset

da.Fill(ds.Tables (表1))
da.Fill(ds.Tables(" Table2"))

da.Fill(ds.Tables(" Table3"))

da .Fill(ds.Tables(" Table4"))

SomeCrystalReport.Database.Tables(" Table1")。SetDat aSource(ds.Tables(" Table1")))


SomeCrystalReport.Database.Tables(" Table2")。SetDat aSource(ds.Tables(" Table2"))


SomeCrystalReport .Database.Tables(" Table3")。SetDat aSource(ds.Tables(" Table3"))

SomeCrystalReport.Database.Tables(" Table4")。SetDat aSource (ds.Tables(" Table4"))


-------------

请发布完整的解决方案(或链接)关于如何更改水晶

在运行时通过vs.net报告sql查询。感谢您的帮助!


一切顺利,


Phin

I need your HELP!

I''ve seen all the posts on using Crystal Reports within vs.net (vb.net)
and changing a SQL query at runtime. When I tried to pass in a dataset
into the crystal report at runtime, the report still showed the results
from the default query (from within the Crystal Report).

Then I tried the XSD solution where you define a dataset (that mataches
the database and the Crystal Report) and have the Crystal Report use
this. All the examples that use the XSD solution use one table. I have
four tables and when I fill up my dataset and pass it to the report,
the report comes up blank (even though there is data in the dataset).
Man, I wish there just was a sqlquery property that I could change!

I''ve tried the following and all bring back a blank report:

---------
strSQL ''a query that joins four tables and bring back results from all
four tables

Dim da As SqlClient.SqlDataAdapter = New
SqlClient.SqlDataAdapter(strSQL, strConnectionString)

Attempt 1.
Dim ds As New System.data.DataSet
da.Fill(ds)
SomeCrystalReport.SetDataSource(ds)

Attempt 2.
Dim ds As New System.data.DataSet
da.Fill(ds, "Table1")
da.Fill(ds, "Table2")
da.Fill(ds, "Table3")
da.Fill(ds, "Table4")
SomeCrystalReport.SetDataSource(ds)

Attempt 3.
Dim ds As New System.data.DataSet
da.Fill(ds, "Table1")
da.Fill(ds, "Table2")
da.Fill(ds, "Table3")
da.Fill(ds, "Table4")

Dim i As Integer = 0
While i < SomeCrystalReport.Database.Tables.Count
SomeCrystalReport.Database.Tables(i).SetDataSource (ds.Tables(i))
i = i + 1
End While

Attempt 4.
Dim ds As New System.data.DataSet
da.Fill(ds, "Table1")
da.Fill(ds, "Table2")
da.Fill(ds, "Table3")
da.Fill(ds, "Table4")

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table1"))

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table2"))

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table3"))

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table4"))
Attempt 5.
Dim ds As New Some_XSD_dataset
da.Fill(ds.Tables("Table1"))
da.Fill(ds.Tables("Table2"))
da.Fill(ds.Tables("Table3"))
da.Fill(ds.Tables("Table4"))

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table1"))

SomeCrystalReport.Database.Tables("Table2").SetDat aSource(ds.Tables("Table2"))

SomeCrystalReport.Database.Tables("Table3").SetDat aSource(ds.Tables("Table3"))

SomeCrystalReport.Database.Tables("Table4").SetDat aSource(ds.Tables("Table4"))

-------------
Please post a complete solution (or links) on how to change a crystal
report sql query at runtime via vs.net. Your help is appreciated!

All the best,

Phin

推荐答案

嗨Phin,


你会以一种我不愿意的方式去做。我做你需要的所有

时间,这里的方法是:我删除一个表(使用sql命令obj)我

recycle,let''称之为ttable。然后我使用''select into''

子句重新创建ttable。然后我运行报告。该报告总是打开ttable,所以它没有关心数据总是不同。


HTH,


Bernie Yaeger


" Phin" <先生****** @ yahoo.com>在消息中写道

news:11 ********************** @ f14g2000cwb.googlegr oups.com ...
Hi Phin,

You''re going about it in a way that I would not. I do what you need all the
time, and here''s how: I delete a table (using an sql command obj) that I
recycle, let''s call it ttable. I then recreate ttable using a ''select into''
clause. I then run the report. The report always opens ttable, so it
doesn''t care that the data is always different.

HTH,

Bernie Yaeger

"Phin" <mr******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
我需要你的帮助!

我已经看到了在vs.net(vb.net)中使用Crystal Reports并在运行时更改SQL查询的所有帖子。当我试图在运行时将数据集传入晶体报告时,报告仍然显示默认查询(来自Crystal报告中)的结果。

然后我尝试了XSD解决方案,您可以在其中定义数据集(用于数据库和Crystal报表)并使用Crystal Report。使用XSD解决方案的所有示例都使用一个表。我有四个表,当我填写我的数据集并将其传递给报告时,报告显示为空白(即使数据集中有数据)。
男,我希望只有一个sqlquery属性,我可以改变!

我已经尝试了以下所有并带回一个空白的报告:

-------- -

strSQL''一个连接四个表并带回所有四个表的结果的查询

Dim da As SqlClient.SqlDataAdapter = New
SqlClient.SqlDataAdapter(strSQL,strConnectionString)

尝试1.
Dim ds As New System.data.DataSet
da.Fill(ds)
SomeCrystalReport.SetDataSource( ds)

尝试2.
Dim ds As New System.data.DataSet
da.Fill(ds," Table1")
da.Fill(ds ,表2)
da.Fill(ds," Table3")
da.Fill(ds," Table4")
SomeCrystalReport.SetDataSource(ds)

尝试3.
Dim ds As New System.data.DataSet
d a.Fill(ds," Table1")
da.Fill(ds," Table2")
da.Fill(ds," Table3")
da.Fill(ds ,表4)

Dim i As Integer = 0
虽然我< SomeCrystalReport.Database.Tables.Count
SomeCrystalReport.Database.Tables(i).SetDataSource(ds.Tables(i))
i = i + 1
结束时

尝试4.
Dim ds As New System.data.DataSet
da.Fill(ds," Table1")
da.Fill(ds," Table2")
da.Fill(ds," Table3")
da.Fill(ds," Table4")

SomeCrystalReport.Database.Tables(" Table1")。SetDat aSource (ds.Tables(" Table1"))

SomeCrystalReport.Database.Tables(" Table1")。SetDat aSource(ds.Tables(" Table2"))

/> SomeCrystalReport.Database.Tables(" Table1")。SetDat aSource(ds.Tables(" Table3")))

SomeCrystalReport.Database.Tables(" Table1")。SetDat aSource( ds.Tables(" Table4"))

尝试5.
Dim ds为新Some_XSD_dataset
da.Fill(ds.Tables(" Table1")))br /> da.Fill(ds.Tables(" Table2"))
da.Fill(ds.Tables(" Tabl) e3"))
da.Fill(ds.Tables(" Table4"))

SomeCrystalReport.Database.Tables(" Table1")。SetDat aSource(ds.Tables(") ;表1))

SomeCrystalReport.Database.Tables(" Table2")。SetDat aSource(ds.Tables(" Table2")))

SomeCrystalReport.Database。表(表3)。SetDat aSource(ds.Tables(" Table3"))

SomeCrystalReport.Database.Tables(" Table4")。SetDat aSource(ds.Tables("表4))

-------------
请发布完整的解决方案(或链接)如何更改水晶报告sql通过vs.net在运行时查询。感谢您的帮助!

一切顺利,

Phin
I need your HELP!

I''ve seen all the posts on using Crystal Reports within vs.net (vb.net)
and changing a SQL query at runtime. When I tried to pass in a dataset
into the crystal report at runtime, the report still showed the results
from the default query (from within the Crystal Report).

Then I tried the XSD solution where you define a dataset (that mataches
the database and the Crystal Report) and have the Crystal Report use
this. All the examples that use the XSD solution use one table. I have
four tables and when I fill up my dataset and pass it to the report,
the report comes up blank (even though there is data in the dataset).
Man, I wish there just was a sqlquery property that I could change!

I''ve tried the following and all bring back a blank report:

---------
strSQL ''a query that joins four tables and bring back results from all
four tables

Dim da As SqlClient.SqlDataAdapter = New
SqlClient.SqlDataAdapter(strSQL, strConnectionString)

Attempt 1.
Dim ds As New System.data.DataSet
da.Fill(ds)
SomeCrystalReport.SetDataSource(ds)

Attempt 2.
Dim ds As New System.data.DataSet
da.Fill(ds, "Table1")
da.Fill(ds, "Table2")
da.Fill(ds, "Table3")
da.Fill(ds, "Table4")
SomeCrystalReport.SetDataSource(ds)

Attempt 3.
Dim ds As New System.data.DataSet
da.Fill(ds, "Table1")
da.Fill(ds, "Table2")
da.Fill(ds, "Table3")
da.Fill(ds, "Table4")

Dim i As Integer = 0
While i < SomeCrystalReport.Database.Tables.Count
SomeCrystalReport.Database.Tables(i).SetDataSource (ds.Tables(i))
i = i + 1
End While

Attempt 4.
Dim ds As New System.data.DataSet
da.Fill(ds, "Table1")
da.Fill(ds, "Table2")
da.Fill(ds, "Table3")
da.Fill(ds, "Table4")

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table1"))

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table2"))

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table3"))

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table4"))
Attempt 5.
Dim ds As New Some_XSD_dataset
da.Fill(ds.Tables("Table1"))
da.Fill(ds.Tables("Table2"))
da.Fill(ds.Tables("Table3"))
da.Fill(ds.Tables("Table4"))

SomeCrystalReport.Database.Tables("Table1").SetDat aSource(ds.Tables("Table1"))

SomeCrystalReport.Database.Tables("Table2").SetDat aSource(ds.Tables("Table2"))

SomeCrystalReport.Database.Tables("Table3").SetDat aSource(ds.Tables("Table3"))

SomeCrystalReport.Database.Tables("Table4").SetDat aSource(ds.Tables("Table4"))

-------------
Please post a complete solution (or links) on how to change a crystal
report sql query at runtime via vs.net. Your help is appreciated!

All the best,

Phin



Bernie,

感谢您的快速回复!我不确定你的意思是删除

表(报告中的哪个表?)并回收。请发布

代码,了解如何执行此操作。我刚看到xsd解决方案和你的方式

听起来更容易。我恭喜你的帮助!


谢谢!


Phin


Bernie Yaeger写道:
Bernie,

Thank you for the quick response! I am not sure what you mean to delete
table (which table? in the report?) and recycle. Please your post the
code on how to do this. I''ve just seen the xsd solution and your way
sounds easier. I apprecaite your help!

Thanks!

Phin

Bernie Yaeger wrote:
嗨Phin,

你会以一种我不愿意的方式去做。我一直在做你需要的
,这里是如何:我删除一个表(使用sql命令obj)
我回收,让我们称之为ttable。然后我使用
''select into''子句重新创建ttable。然后我运行报告。报告总是打开ttable,所以
它并不关心数据总是不同。

HTH,
Hi Phin,

You''re going about it in a way that I would not. I do what you need all the time, and here''s how: I delete a table (using an sql command obj) that I recycle, let''s call it ttable. I then recreate ttable using a ''select into'' clause. I then run the report. The report always opens ttable, so it doesn''t care that the data is always different.

HTH,






Phin napisa3(a):
Phin napisa3(a):
我需要你的帮助!

我看过在vs.net中使用Crystal Reports的所有帖子(vb.net)
并在运行时更改SQL查询。当我试图在运行时将数据集传入晶体报告时,报告仍然显示默认查询(来自Crystal Report中)的结果。
I need your HELP!

I''ve seen all the posts on using Crystal Reports within vs.net (vb.net)
and changing a SQL query at runtime. When I tried to pass in a dataset
into the crystal report at runtime, the report still showed the results
from the default query (from within the Crystal Report).




您是否尝试使用Refresh方法?



Did You try to use Refresh method?


这篇关于通过vs.net帮助在运行时更改Crystal Report sql查询。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆