Creating Crystal report from two tables
Creating Crystal report from two tables
Creating Crystal report from two tables
Creating Crystal report from two tables
Creating Crystal report from two tables
Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables
Creating Crystal report from two tables Creating Crystal report from two tables
Creating Crystal report from two tables
Go Back  Xtreme Visual Basic Talk > > > Creating Crystal report from two tables


Reply
 
Thread Tools Display Modes
  #1  
Old 12-20-2011, 02:52 PM
cherosoullis cherosoullis is offline
Freshman
 
Join Date: Jun 2006
Posts: 39
Default Creating Crystal report from two tables


Hello,

I am trying to load a crystal report from two tables but it seems that is not working.

Here is the code to load the crystal report:


Code:
   Private Sub InvoiceLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim Cnn As New SqlConnection
        Try
            If Cnn.State = ConnectionState.Open Then Cnn.Close()
            Cnn.ConnectionString = My.MySettings.Default.GarageConnectionString
            Cnn.Open()

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "error")
            End
        End Try

        Dim InvoiceNoFind As Integer

        If CreateInvoiceQuery.InvoiceWorksDataGridView.SelectedRows.Count = 0 And CreateInvoiceQuery.InvoiceWorksDataGridView.RowCount = 0 And CreateInvoiceQuery.InvoiceWorksDataGridView.SelectedCells.Count = 0 Then
            MessageBox.Show("Print not allowed as no row/cell is selected!", "Garage", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Exit Sub
        End If

        'If cell only is selected, use this to find the UserID
        If CreateInvoiceQuery.InvoicesDataGridView.SelectedRows.Count = 0 And CreateInvoiceQuery.InvoicesDataGridView.SelectedCells.Count > 0 Then
            InvoiceNoFind = CType(CreateInvoiceQuery.InvoicesDataGridView.Rows(CreateInvoiceQuery.InvoicesDataGridView.SelectedCells(0).RowIndex).Cells("DataGridViewTextBoxColumn8").Value, Integer)
            'If full row is selected, use this to find the UserID
        ElseIf CreateInvoiceQuery.InvoicesDataGridView.SelectedRows.Count > 0 And CreateInvoiceQuery.InvoicesDataGridView.SelectedCells.Count > 0 Then
            InvoiceNoFind = CType(CreateInvoiceQuery.InvoicesDataGridView.Rows(CreateInvoiceQuery.InvoicesDataGridView.SelectedCells(0).RowIndex).Cells("DataGridViewTextBoxColumn8").Value, Integer)
        End If


        Dim Report As New PrintInvoice
        Dim Dt As New DataTable
        Dim query As String
        Dim Com As New SqlCommand
        Dim DA As New SqlDataAdapter
        'Dim applicationPath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0).FullyQualifiedName)

        query = "select * from Invoices where InvoiceNo = '" & InvoiceNoFind.ToString & "'"


        Com = New SqlCommand(query, Cnn)
        DA.SelectCommand = Com
        DA.SelectCommand.CommandType = CommandType.Text
        DA.Fill(Dt)
        'Debug.Print(Dt.Rows.Count.ToString)
        'MessageBox.Show(Dt.Rows.Count.ToString)
        'Report.Load(applicationPath & "\PrintInvoice.rpt")
        Report.SetDataSource(Dt)
        CrystalReportViewer1.ReportSource = Report
        'CrystalReportViewer1.Show()

        'PrintSelectedInvoice()
    End Sub
Thanks in advance.
Reply With Quote
  #2  
Old 01-04-2012, 03:22 AM
Orca44 Orca44 is offline
Centurion
 
Join Date: Nov 2004
Location: Cape Town, South Africa
Posts: 124
Default

Which two tables are you using? Your example states only
Code:
"select * from Invoices where..."
What error message is being returned when you try to generate the report?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Creating Crystal report from two tables
Creating Crystal report from two tables
Creating Crystal report from two tables Creating Crystal report from two tables
Creating Crystal report from two tables
Creating Crystal report from two tables
Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables Creating Crystal report from two tables
Creating Crystal report from two tables
Creating Crystal report from two tables
 
Creating Crystal report from two tables
Creating Crystal report from two tables
 
-->