creating and populating a crystal report using a dataset and text boxes

I'm new at using VB.net and I have a form that clears and fills a dataset upon a change in text in a  text box on my form. I'd like to print a crystal report after clicking on the print command button. I'm using visual studio 2002 and the crystal reports that came with it.  I've reviewed quite a few previously posted solutions and have become more confused with the different approaches. I've attached the database connection, the data adapter and the dataset to the form and placed this code in the "txtNDC_TextChanged" for the text box

' Get the Parameter object and Set value
        With SqlDataDrugVw.SelectCommand.Parameters
            .Item("@ndcparam").Value = _
            txtNDC.Text()

        End With

        ' Clear the dataset
        VphDrugs.Clear()
        ' Load the dataset using the parameter value
        Try
            SqlDataDrugVw.Fill(VphDrugs, "vphdrugs")

        Catch ex As Exception

            MessageBox.Show(ex.ToString)

        End Try

It fills the dataset  as I have two other objects displaying information from the datset after it updates.
Now generally a user will enter information into two other text boxes and hit print.

When they hit print I'd like the report to automatically print at the printer, without the user visibly having to look at it.

I've reviewed a link to a solution "vbnet_win_pass_dataset_main_sub" and couldn't figure out how he created the report without an actual connection through the designer. Although the solution works fine and does what it's supposed to when I run it.

Thanks in advance

dlubonskiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JRossi1Commented:
A differenct approach:  Consider this:  after creating your dataset, create an XML file based on your database:

VphDrugs.WriteXml("C:\CrystalReports\CrystalReport.xml")

Then you can use the Crystal Report Wizard to point to the XML file to create your report.  Each time the dataset is created, the XML file is updated and so will the report.

Hope this helps...

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JRossi1Commented:
correction:  I meant dataset NOT database.
0
dlubonskiAuthor Commented:
That does allow me to report the data initially in the dataset but doesn't capture the two text fields where the end user enters additional input. I've added the two fields to the dataset so the attributes appear in the XML file when created and can be part of the report, but how do i update the XML just before the report prints?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

JRossi1Commented:
When the user clicks on the print button, just write the DataSet to the XML file again:  VphDrugs.WriteXml("C:\CrystalReports\CrystalReport.xml")
0
dlubonskiAuthor Commented:
Let me clarify the whole process, so I'm not asking the wrong question.

1) The end user scans a barcode and the datset is created based upon the information tied to it.
2) The end user populates an expiration date of the product into a text field.
3) The end user populates a mfg lot number based on the manufacturing run.
4) The end user prints a label / report to be used later so the physical product doesn't have to go through the workflow.

So I have a dataset created prior to the manual entry of the expiration date and lot number.

Should I update the dataset and then write out the xml file or

Should I write out the xml file and then update the elements/nodes when the user hits print just before the report prints?
0
JRossi1Commented:
If the user doesn't need to see the data they manually enter into the text boxes on-screen, then create/update the xml file when the user clicks the print button.
0
dlubonskiAuthor Commented:
Can you make a suggestion on the correct way to update the xml file or point me in the right direction?
0
JRossi1Commented:
Here is sample code to write to an XML file:

' create a connection string
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Northwind.mdb"
Dim myConnection As OleDbConnection = New OleDbConnection()
myConnection.ConnectionString = connString
' create a data adapter
Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from Customers", myConnection)
' create a new dataset
Dim ds As DataSet = New DataSet()
' fill dataset
da.Fill(ds, "myTable")
' write dataset contents to an xml file by calling WriteXml method
ds.WriteXml("C:\\CustTableDt.xml")

If the XML file already exists the 'writeXml' method will overwrite the file, hence updating it.


Take a look at this web site.  It contains good information regarding this topic:  http://www.vbdotnetheaven.com/Code/Jul2003/2120.asp
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.