473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

HELP on Changing Crystal Report sql query at run time via vs.net.

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

Jul 21 '05 #1
7 3945
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...
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

Jul 21 '05 #2
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:
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,


Jul 21 '05 #3
Phin napisał(a):
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).


Did You try to use Refresh method?
Jul 21 '05 #4
Thanks Bernie, Fang, et al for your help!

I was crunched for time, so I just used the Craxdrt (interop) dll with
VB.net like I would have done in the pre-VB.NET days (and pass the
query via a sqlquery property)!

What it takes to update a query in Crystal Reports in .NET starts
looking like a Rube Goldberg invention:
http://www.rube-goldberg.com/

Don't get me wrong, I love .NET (and have used it since the beta back
in the 2000). I just wished they would have a sqlquery property exposed
or at least make Microsoft Reporting Services easier to implement (in a
production environment) and convert over to (hopefully with RS 2.0 and
SQL server 2005), so I can leave Crystal and its ambiguous error
messages and over-priced licensing behind!

I feel better now that I got that off my chest!

: )

Phin

Jul 21 '05 #5
Hi Phin,

I know how you feel, but I'm afraid we're not going to see Reporting
Services robust enough for a production environment for at least 2 years.
So we still have to live with the difficulties that Crystal imposes.

Regards,

Bernie

"Phin" <mr******@yahoo.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Thanks Bernie, Fang, et al for your help!

I was crunched for time, so I just used the Craxdrt (interop) dll with
VB.net like I would have done in the pre-VB.NET days (and pass the
query via a sqlquery property)!

What it takes to update a query in Crystal Reports in .NET starts
looking like a Rube Goldberg invention:
http://www.rube-goldberg.com/

Don't get me wrong, I love .NET (and have used it since the beta back
in the 2000). I just wished they would have a sqlquery property exposed
or at least make Microsoft Reporting Services easier to implement (in a
production environment) and convert over to (hopefully with RS 2.0 and
SQL server 2005), so I can leave Crystal and its ambiguous error
messages and over-priced licensing behind!

I feel better now that I got that off my chest!

: )

Phin

Jul 21 '05 #6
Are you saving data in the report? You can check the .HasSavedData
property. If you do, it will show and ignore your datasource.

"Phin" <mr******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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

Jul 21 '05 #7
I would like to chime in here if you don't mind. Yes, there is definitely a
problem with the CR.NET API. It needs to be fleshed out more. Things are
going to be much better in CR.NET 2005. Secondly, re Reporting Services, I
love how everyone thinks this is a free tool that is easy to use. Have you
read the RS newsgroups and the problems people are having? That might shed
some light on where RS is at in development. And it's only free when you
read the marketing brochures. Put it on a production server and it won't be
long before you are buying a second server and another SQL license to boot.
Want to use ASP.NET Forms Authentication? That will be another $20K, thank
you. Trust me, MS didn't become the world's largest software company by
giving away its software for free. Otherwise we would be getting MS Office
cds in the mail right next to the AOL cds. Also, CR Server is much cheaper
now that RS is in the marketplace (competition has a way of doing that...).
So keep dreaming about RS and how great it is, but until you go through the
pain of getting around its bugs and limited feature set ("Just write more
custom data extensions!") then stick with Crystal.

Brian
"Scott Wallace" <sc***********@astyles.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
Are you saving data in the report? You can check the .HasSavedData
property. If you do, it will show and ignore your datasource.

"Phin" <mr******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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


Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: RJN | last post by:
Hi I'm new to VS.Net Crystal Report. I'm using data sets as the source for crystal report. I've a dataset which has 2 data tables. The first table's schema is like this Ptid String Prid...
10
by: Phin | last post by:
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...
1
by: mike11d11 | last post by:
For some reason I'm getting no data populating in my crystal report. I built my crystal report off my dataset in my project, and I fill the dataset when opening the main form, and count the...
11
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
How can I stop receiving this message while calling a crystal report? "The report you requested requires further information." Thanks
3
by: muddasirmunir | last post by:
i am using vb6 and crystal report 10 i want to ask solution of one proble which i am facing in making report. first , in my programe i ask the user to give paramerter (range) of the data...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.