本文介绍了如何使用数据集中的选择查询制作水晶报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

呵呵!实际上,我想制作水晶报表,该数据源是数据集,但是问题是在我的应用程序中,我创建了一个按钮和文本框,然后拖动crystalreportviewer,当我将id插入文本框并按下按钮时,我想这样做,水晶报表仅显示插入的ID和栏目
这是下面的代码,请帮我解决这个问题

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

Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form1
    Inherits System.Windows.Forms.Form


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


end class

推荐答案


这篇关于如何使用数据集中的选择查询制作水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 12:49