Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: CrystalReports
I am trying to create a Crystal Report with a dynamic data source. When i click the report button, the crystal report shows up just fine, but when i click any button the Crystal Report tool bar (i.e. Next page, Export To, etc.), i get a pop with the Error "No valid report source is available."
My Report viewer coding:
 
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpApplication
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Imports CrystalDecisions.ReportSource
 
Partial Class Reportviewer
Inherits System.Web.UI.Page
Public str As String
Public rptname As String
Public sf As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = False Then
Dim printModeList As ArrayList = New ArrayList()
printModeList.Add("ActiveX")
Dim con As New ConnectionInfo
Dim con1 As New ConnectionInfo
Dim db1 As Database
Dim dbs As Tables
Dim db As Table
Dim tab As TableLogOnInfo
rptname = Session("rptname")
str = Convert.ToString(Session("Str")) '"
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
 
With con
.UserID = "sa"
.Password = "sa"
.DatabaseName = "TASHEEL"
' .ServerName = "Develope-PC"
.ServerName = "TASHEEL"
 
End With
If rptname = "inv_rep.rpt" Then
rpt.Load(Server.MapPath("..\Report\CrystalReport.rpt"))
End If
db1 = rpt.Database
dbs = db1.Tables
For Each db In dbs
tab = db.LogOnInfo
tab.ConnectionInfo = con
db.ApplyLogOnInfo(tab)
Next
CrystalReportViewer1.SelectionFormula = str
'rptname = Session("rptname") '"INV_LIST.rpt"
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.ShowFirstPage()
'CrystalReportViewer1.RefreshReport()
Session("Str") = ""
Session("rptname") = ""
 
End If
End Sub

End Class
Posted 19-Apr-13 20:47pm

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 20 Oct 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100