Results 1 to 4 of 4

Thread: [ RESOLVED ] Binding Two tables to a Crystal Report

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2011
    Posts
    17

    [ RESOLVED ] Binding Two tables to a Crystal Report

    Many thanks for all those who helped me to date. I have another issue. I have created a crystal report with two tables, one for company details as a header and one for report details as a filler.

    I have been trying to get dates to filter the report and have done so successfully but the header part of the report does not show any data at all. I have binded the crystal report using a report viewer. Here is code i use to call crystal report. Lets say second table is called Company details, how do i get this information to show up with rescinded documents information. I have attached a copy fo what my final report will look like.


    Private Sub BtnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOpen.Click
    Dim sqlsearch As String
    Dim con As New OleDb.OleDbConnection

    Dim hugh As Date = DateTimePicker1.Value.Date
    Dim hugh2 As Date = DateTimePicker2.Value.Date.AddDays(1)


    sqlsearch = "SELECT * FROM TableRescindedDocuments, TableCompany Details WHERE DateRescinded BETWEEN @startDate AND @endDate"

    con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\FoodQualityDB1.accdb"


    ' Once again we execute the SQL statements against our DataBase

    Dim adapter As New OleDbDataAdapter(sqlsearch, con)

    With adapter.SelectCommand.Parameters
    .AddWithValue("@startDate", hugh)
    .AddWithValue("@endDate", hugh2)
    End With

    ' Shows the records and updates the DataGridView

    Dim dt As New DataTable("TableRescindedDocuments")

    adapter.Fill(dt)
    Dim rpt As New CrystalReportRescindedDocuments

    rpt.SetDataSource(dt)
    RepResDoc.CrystalReportViewer1.ReportSource = rpt
    RepResDoc.Show()
    Me.Close()
    End Sub
    Attached Images Attached Images  
    Last edited by donhughberto; May 13th, 2011 at 07:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width