Kudzullc
asked on
Crystal Report with dynamic query inside VB.NET
Hi Experts,
I am having trouble with creating a dataset with a dynamic query and using this dataset to populate a Crystal Report. I have tried two ways. The frist was to plainly create the dataset and set the datasource and show the form with the report inside. Nothing happens. Second try was creating an XML and have the report use the fields as parameters to no avail. I am stuck and this project is very important to our IT Staff. I will show some code.
1st Try:
Dim newView As New rptViewProject
Dim newfrmReport As New frmReport
Dim myDataAdapter As New OleDb.OleDbDataAdapter
myDataAdapter.Fill(myDataS et)
Dim myDataSet As New DataSet
myDataAdapter.SelectComman d = New OleDb.OleDbCommand("Select * from items", cnOleDb)
newView.SetDataSource(MyDa taSet)
newfrmReport.CrystalReport Viewer1.Re portSource = newView
newfrmReport.ShowDialog()
returns a blank report. Is there anything I need to have set in Crystal tht I might be missing? I know its a vague question but the use of database fields or parameters means different report builds. I have done the necessary steps to build the report properly ( I think) I do have other reports for other programs but the all have static information and are not queried.
2nd Try (XML):
Dim newView As New rptViewProject
Dim newfrmReport As New frmReport
Dim myDataAdapter As New OleDb.OleDbDataAdapter
Dim myDataSet As New DataSet
myDataAdapter.SelectComman d = New OleDb.OleDbCommand("Select * from items", cnOleDb)
myDataAdapter.Fill(myDataS et)
Dim result As String = myDataSet.GetXml()
Dim fileName As String = "c:\temp\Listings.xml"
Dim sw As IO.StreamWriter = New IO.StreamWriter(fileName)
sw.Write(result)
sw.Flush()
sw.Close()
newView.SetDataSource("c:\ temp\Listi ngs.xml")
newfrmReport.CrystalReport Viewer1.Re portSource = newView
newfrmReport.ShowDialog()
Nothing here either. Thanks for your time in advance. I have looked through EE very thoroughly and got here but I can not seem to locate the information I think I am missing.
Thanks again!
Lucas
I am having trouble with creating a dataset with a dynamic query and using this dataset to populate a Crystal Report. I have tried two ways. The frist was to plainly create the dataset and set the datasource and show the form with the report inside. Nothing happens. Second try was creating an XML and have the report use the fields as parameters to no avail. I am stuck and this project is very important to our IT Staff. I will show some code.
1st Try:
Dim newView As New rptViewProject
Dim newfrmReport As New frmReport
Dim myDataAdapter As New OleDb.OleDbDataAdapter
myDataAdapter.Fill(myDataS
Dim myDataSet As New DataSet
myDataAdapter.SelectComman
newView.SetDataSource(MyDa
newfrmReport.CrystalReport
newfrmReport.ShowDialog()
returns a blank report. Is there anything I need to have set in Crystal tht I might be missing? I know its a vague question but the use of database fields or parameters means different report builds. I have done the necessary steps to build the report properly ( I think) I do have other reports for other programs but the all have static information and are not queried.
2nd Try (XML):
Dim newView As New rptViewProject
Dim newfrmReport As New frmReport
Dim myDataAdapter As New OleDb.OleDbDataAdapter
Dim myDataSet As New DataSet
myDataAdapter.SelectComman
myDataAdapter.Fill(myDataS
Dim result As String = myDataSet.GetXml()
Dim fileName As String = "c:\temp\Listings.xml"
Dim sw As IO.StreamWriter = New IO.StreamWriter(fileName)
sw.Write(result)
sw.Flush()
sw.Close()
newView.SetDataSource("c:\
newfrmReport.CrystalReport
newfrmReport.ShowDialog()
Nothing here either. Thanks for your time in advance. I have looked through EE very thoroughly and got here but I can not seem to locate the information I think I am missing.
Thanks again!
Lucas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the advice! I will try it out!
Lucas
Lucas
ASKER
I used the idea and I have it working. Instead of Crystal Reports I used PrinterClass and used a template. Maybe a little more work then I anticipated but it does exactly what I need it to! Thanks for the help!
Lucas
Lucas
Glad it got you moving again :)
ASKER
I created seperate .rpt files to except parameters in one and database fields in the other.
Lucas