P
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").SetDataSource(ds.Tables("Table1"))
SomeCrystalReport.Database.Tables("Table1").SetDataSource(ds.Tables("Table2"))
SomeCrystalReport.Database.Tables("Table1").SetDataSource(ds.Tables("Table3"))
SomeCrystalReport.Database.Tables("Table1").SetDataSource(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").SetDataSource(ds.Tables("Table1"))
SomeCrystalReport.Database.Tables("Table2").SetDataSource(ds.Tables("Table2"))
SomeCrystalReport.Database.Tables("Table3").SetDataSource(ds.Tables("Table3"))
SomeCrystalReport.Database.Tables("Table4").SetDataSource(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
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").SetDataSource(ds.Tables("Table1"))
SomeCrystalReport.Database.Tables("Table1").SetDataSource(ds.Tables("Table2"))
SomeCrystalReport.Database.Tables("Table1").SetDataSource(ds.Tables("Table3"))
SomeCrystalReport.Database.Tables("Table1").SetDataSource(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").SetDataSource(ds.Tables("Table1"))
SomeCrystalReport.Database.Tables("Table2").SetDataSource(ds.Tables("Table2"))
SomeCrystalReport.Database.Tables("Table3").SetDataSource(ds.Tables("Table3"))
SomeCrystalReport.Database.Tables("Table4").SetDataSource(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