Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My project is running successfully but i have one problem in that project that it can not show the data after saving , it show the Crystal Report but in this it can't show the data

Please see the below mentioned code and solve the same


VB
Dim insql As String = "INSERT INTO patient (recptno,pname,age,address,date,phone,refby,testcode,testname,amount) VALUES (@number1,@text2,@number3,@text4,@text5,@number6,@text7,@text8,@text9,@number10)"

        cmd = New SqlCommand(insql, sqlconn)


        cmd.Parameters.AddWithValue("@number1", reciepttxt.Text)
        cmd.Parameters.AddWithValue("@text2", nametxt.Text)
        cmd.Parameters.AddWithValue("@number3", agetxt.Text)
        cmd.Parameters.AddWithValue("@text4", addresstxt.Text)
        cmd.Parameters.AddWithValue("@text5", datetxt.Text)
        cmd.Parameters.AddWithValue("@number6", phonetxt.Text)
        cmd.Parameters.AddWithValue("@text7", refbytxt.Text)
        cmd.Parameters.AddWithValue("@text8", testcodetxt.Text)
        cmd.Parameters.AddWithValue("@text9", testnametxt.Text)
        cmd.Parameters.AddWithValue("@number10", amounttxt.Text)

        sqlconn.Open()

        rowsins = cmd.ExecuteNonQuery
        sqlconn.Close()

        MessageBox.Show(rowsins.ToString & " row added")

        Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
        Dim CrystalReportViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
        CrystalReportViewer.ActiveViewIndex = 0
        CrystalReportViewer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        CrystalReportViewer.DisplayGroupTree = False
        CrystalReportViewer.Dock = System.Windows.Forms.DockStyle.Fill
        CrystalReportViewer.Location = New System.Drawing.Point(0, 0)
        CrystalReportViewer.Name = "CrystalReportViewer1"

        Dim ds As New MDataSet
        Dim sqlCon As SqlConnection
        Dim dt As New DataTable
        dt.TableName = "patient"
        Form2.Show()
        sqlCon = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=blissdata;Integrated Security=True")
        Dim da As New SqlDataAdapter("SELECT recptno,pname,age,address,date,phone,refby,testcode,testname,amount FROM patient", sqlCon)
        da.Fill(dt)

        Report.Load("C:\Users\Administrator\Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\CrystalReport1.rpt")

        Report.SetDataSource(ds)

        Form2.CrystalReportViewer1.ReportSource = Report

        'Form2.CrystalReportViewer1.Refresh()
Posted
Comments
Sandeep Mewara 4-Mar-11 5:38am    
Any error?
Mudasar Ahmad 4-Mar-11 23:50pm    
there is no error
Sunasara Imdadhusen 4-Mar-11 6:11am    
Is there any error?
thatraja 4-Mar-11 11:45am    
Tell me the error message man, I'll give you the solution quickly
Mudasar Ahmad 4-Mar-11 23:49pm    
there is no error that is why i confused

1 solution

Ok.

I looked at your code since you said no error. Noticed one thing:
You do:
Report.SetDataSource(ds)


Though, ds was never populated.
Instead, dt was:
da.Fill(dt)


So, change it and try something like:
Report.SetDataSource(dt)


See, if it helps.
 
Share this answer
 
Comments
Mudasar Ahmad 5-Mar-11 0:56am    
thanks for help dear
Mudasar Ahmad 5-Mar-11 1:32am    
but next time when i entered a new data but it show the previous data again
Ali Al Omairi(Abu AlHassan) 5-Mar-11 7:18am    
it is me too!!
Mudasar Ahmad 7-Mar-11 3:50am    
then what we can do

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900