TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vinay NV
NA
22
6.6k
Bind dataset with Crystal Report ?
Aug 7 2013 12:26 PM
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
Reply
Answers (
2
)
Commenting postin of "http://www.c-sharpcorner.com/"
how to create a touch screen application using .net