Visual Studio localhost Port casuing problems for Crystal Reports in ASP.Net

Last Reply on Aug 10, 2013 01:08 AM By Mudassar

Posted on Aug 08, 2013 09:10 AM

Hi, I have created a dataset with 3 tables and trying to fill this dataset using dataadapter(By executing stored procedure). The data is getting filled into the dataset but it is not getting displayed in the crystal report(Getting blank report). Pls refer by code below :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
namespace CrystalEx
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string sqlCon = "Server=ServerName;Database=DBName;uid=sa;pwd=sa;connection timeout=3600;";
SqlConnection sqlConn = new SqlConnection(sqlCon);

SqlDataAdapter sqlAdap = new SqlDataAdapter();
//TQReportCM is a stored procedure , i am selecting a record by passing one parameter 
sqlAdap.SelectCommand = new SqlCommand("TQReportCM", sqlConn);
sqlConn.Open();
DataSet1 ds = new DataSet1();

sqlAdap.SelectCommand.CommandType = CommandType.StoredProcedure;
sqlAdap.SelectCommand.Connection = sqlConn;
sqlAdap.SelectCommand.Parameters.Add("@CmNo", SqlDbType.NVarChar, 400).Value = "1";
sqlAdap.Fill(ds, ds.CM.TableName);

//TQReportCRPOCis a stored procedure , i am selecting a record by passing one parameter
sqlAdap.SelectCommand = new SqlCommand("TQReportCRPOC", sqlConn);
sqlAdap.SelectCommand.CommandType = CommandType.StoredProcedure;
sqlAdap.SelectCommand.Connection = sqlConn;
sqlAdap.SelectCommand.Parameters.Add("@Name", SqlDbType.NVarChar, 400).Value = "hello";
sqlAdap.Fill(ds, ds.CRPOC.TableName);
//TQReportSelectHS is a stored procedure , i am selecting a record by passing one parameter


sqlAdap.SelectCommand = new SqlCommand("TQReportSelectHS", sqlConn);
sqlAdap.SelectCommand.CommandType = CommandType.StoredProcedure;
sqlAdap.SelectCommand.Connection = sqlConn;
sqlAdap.SelectCommand.Parameters.Add("@FirstName", SqlDbType.NVarChar, 400).Value = "abcd";

sqlAdap.Fill(ds, ds.Customer.TableName);
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("CrystalReport1.rpt"));


rptDoc.SetDataSource(ds);

CrystalReportViewer1.DataBind();
CrystalReportViewer1.ReportSource = rptDoc;
}

}
}

Any help would be appreciated.
Thanks in advance

Posted on Aug 10, 2013 01:08 AM

Such thing should not happen, seems like you have installed IIS on your development machine which might be intefering with ASP.Net Server