Last post Apr 12, 2012 11:14 AM by PGChoudhury
Apr 11, 2012 10:10 AM|PGChoudhury|LINK
Here is the code that I am using to load the report. Hope it helps to understand the situation.
protected void Page_Load(object sender, EventArgs e)
string dept = Request.QueryString["dep"];
string str = "select emp_fname, emp_lname, emp_city, emp_country from EmployeeRecords where emp_department='" + dept + "'";
SqlDataAdapter sda = new SqlDataAdapter(str, scon);
DataSet ds = new DataSet();
ReportDocument rpt = new ReportDocument();
DataSet1 ds1 = new DataSet1();
CrystalReportViewer1.ReportSource = rpt;
Apr 12, 2012 06:03 AM|mastriy|LINK
In the first time when you design the report, what kind of connection did you make? If you use NOT the odbc, then i usually use this to by pass the question about server, dbname, etc.
Dim report As ReportDocument = New myreport '(myreport is myreport.rpt)'
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
Dim CrTable As Table
Dim myConnInfo As New ConnectionInfo
.ServerName = _server
.DatabaseName = _database
.UserID = _database
.Password = _password
CrTables = report.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = myConnInfo
'crv is Crystal Report Viewer'
crv.ReportSource = report
Hope this helps.
Apr 12, 2012 11:14 AM|PGChoudhury|LINK
I have solved the problem. Actually I was making a mistake while assigning the datasource for the report document object. It should be the object of the dataset which I created using wizard instead of the one which I am populating using query. The application
is running fine now. The report is loading effortlessly without prompting for any additional informations.
Thanks anyways for the co-operation. Cheers.