Click here to Skip to main content
15,888,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir i am new here regarding crystal reports, sir where could i get the datasource of the crystalreportviewer?
VB
Dim cn As New SqlConnection
       cn.ConnectionString = ("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
       cn.Open()
       Try
           Dim ds As New DataSet
           Dim da As New SqlDataAdapter(mReportDataSource, cn)
           da.Fill(ds)

plss help
Posted
Updated 29-May-11 17:14pm
v2

// Connection Class Code 

Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Public Class Connection
    Public con As New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ToString())
    Public cmd As New SqlCommand
    Public adp As New SqlDataAdapter
    Public ds As New DataSet
    Public dr As SqlDataReader
End Class

//Main Form Code 

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.UI.HtmlControls
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Enterprise
Imports CrystalDecisions.Shared
Imports System.IO
Imports System.Data.SqlClient

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
        Dim rpt As New ReportDocument()
        rpt.Load(Server.MapPath("studentReport.rpt"))
        cn.con.Open()
        cn.cmd.Connection = cn.con
        cn.cmd.CommandText = "select * from Student_Master "
        cn.adp.SelectCommand = cn.cmd
        cn.adp.Fill(cn.ds)
        rpt.SetDataSource(cn.ds.Tables(0))
        CrystalReportViewer1.ReportSource = rpt
        cn.con.Close()
End Sub

kabir.ali999@gmail.com
-
 
Share this answer
 
There is a snippet in vs to get the data source of of crystal report viewer.

VB
Dim report As New ReportDocument()
Dim server as String 'to get Server Name
Dim DBName as String 'to get Database Name
report.Load("rptPatient.rpt")
server=report.DataSourceConnections(0).ServerName
DBName=report.DataSourceConnections(0).DatabaseName


Here Server give the name of server in the report (first connection). And DBName gives the name of Data Base.

Thanks.
 
Share this answer
 
This article explains all the details

Crystal Reports in ASP.NET[^]
 
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