Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

select multiple values from different tables

$
0
0

Good Day everyone,here i am again looking for solution. can anyone help my with this code. i'm creating a report (End Of Shift). i want to get all the details from my tables named (loghistory,usertbl,actualguesting). they dont have common fields. this is my code:

 

first try command display the data of actualguesting in my report.but when put the others,it does'nt display anything plus it prompts database logon

 

If ComboBox1.Text = "End of Shift" Then

            Dim rpt As New EndofShift() 'The report you created.

            Dim MyCommand As New SqlCommand()

            Dim myDA As New SqlDataAdapter()

            Dim myDS As New DSactualguesting() 'The DataSet you created.

            Dim myDS2 As New DSloghistory() 'The DataSet you created.

            Dim myDA2 As New SqlDataAdapter()

            Dim myDS3 As New DSusertbl() 'The DataSet you created.

            Dim myDA3 As New SqlDataAdapter()

            Dim cn As New SqlConnection(ConnectString())

            Dim time As DateTime = DateTime.Now

 

 

            Try

 

 

                MyCommand.Connection = cn

                MyCommand.CommandText = "SELECT * FROM actualguesting"

                MyCommand.CommandType = CommandType.Text

                myDA.SelectCommand = MyCommand

                myDA.Fill(myDS, "actualguesting")

 

 

                myDS.EnforceConstraints = False

                rpt.SetDataSource(myDS)

                CrystalReportViewer1.ReportSource = rpt

            Catch Excep As Exception

                MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            End Try

 

 

 

 

            Try

 

 

                MyCommand.Connection = cn

                MyCommand.CommandText = "SELECT * FROM loghistory where loggedin='" + time.ToShortTimeString + "'"

                MyCommand.CommandType = CommandType.Text

                myDA2.SelectCommand = MyCommand

                myDA2.Fill(myDS2, "loghistory")

 

 

                myDS2.EnforceConstraints = False

                rpt.SetDataSource(myDS2)

                CrystalReportViewer1.ReportSource = rpt

            Catch Excep As Exception

                MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK,MessageBoxIcon.Error)

            End Try

 

 

            Try

 

 

                MyCommand.Connection = cn

                MyCommand.CommandText = "SELECT * FROM usertbl where username='" + Login.txtuser.Text + "'"

                MyCommand.CommandType = CommandType.Text

                myDA3.SelectCommand = MyCommand

                myDA3.Fill(myDS3, "usertbl")

 

 

                myDS3.EnforceConstraints = False

                rpt.SetDataSource(myDS3)

                CrystalReportViewer1.ReportSource = rpt

            Catch Excep As Exception

                MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            End Try

          

        End If


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>