Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hellow! Actually i want to make crystal report which datasource is dataset but problem is that in my application i create a button and textbox and drag crystalreportviewer and i want to do that when i insert the id in textbox and press the button, the crystal report show only inserted id and coloumns
here is my code below please help me out of this
VB
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form1
    Inherits System.Windows.Forms.Form

VB
Dim newCmd As OleDbCommand
    Dim conn As OleDbConnection
    Dim da As New OleDbDataAdapter
    Dim ds As New DataSet2
    Dim cr As New CrystalReport1

    conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=stdb.mdb;Persist Security Info=False")
    newCmd = conn.CreateCommand()
    newCmd.Connection = conn
    newCmd.CommandText = "select Challan_No, Date, Name from stdb where Challan_No = '" & TextBox1.Text & "'"
    da = New OleDbDataAdapter(newCmd)
    da.Fill(ds, "stdb")

    cr = New CrystalReport1()
    cr.SetDataSource(ds)
    CrystalReportViewer1.ReportSource = cr
    conn.Close()
    newCmd.Cancel()
End Sub

end class
Posted
Updated 1-Sep-12 23:27pm
v2

1 solution

Dont create the object of crystal report.
just give crystalreport1.setdatasource
 
Share this answer
 

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