Print Page | Close Window

my crystal report not work online

Printed From: Crystal Reports Book
Category: General Information
Forum Name: Announcements
Forum Discription: Please check this section for the latest announcements from Crystal Reports Forum
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=12112
Printed Date: 02 May 2024 at 9:36am


Topic: my crystal report not work online
Posted By: sarooptrivedi
Subject: my crystal report not work online
Date Posted: 19 Jan 2011 at 3:22pm
Hey...
 
I have work on crystal report and ms access.. my application work properly 2days before but now it's not work...
i can't get what is a problem.. my site just under waiting mode.. it's not through any error...here i paste my code.. if u got any error please tell me
 
my online example:college.vnsguexam.org
 
mycode is:

public partial class _Default : System.Web.UI.Page

{

OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["SGUConn"].ConnectionString);

ReportDocument dc = new ReportDocument();

DataSet ds = new DataSet();

protected void Page_Load(object sender, EventArgs e)

{

reportconnection();

lblmsg.Text = "Hello";

}

public void reportconnection()

{

string sql = string.Empty;

sql = "select * from bba35 where seat_no=10";// order by seat_no";

ConnectionInfo ConnInfo = new ConnectionInfo();

ConnInfo.DatabaseName = "UNI.mdb";

ConnInfo.IntegratedSecurity = true;

int i = -1;

try

{

OleDbDataAdapter da = new OleDbDataAdapter();

conn.Open();

da = new OleDbDataAdapter(sql, conn);

i = da.Fill(ds, tablename);

if (i == 0)

{

lblmsg.Text = "record not found...!!";

}

else

{

dc.Load(Server.MapPath("cr1.rpt"));

dc.SetDataSource(ds);

CrystalReportViewer1.ReportSource = dc;

CrystalReportViewer1.DataBind();

CrystalReportViewer1.RefreshReport();

conn.Close();

}

}

catch (Exception ex)

{

lblmsg.Text = "Result not updated...please wait...!!" + ex.Message;

}

finally {

conn.Close();

}

}

public void Page_UnLoad(object sender, EventArgs e)

{

dc.Close();

dc.Dispose();

}

}

my connectionstring in webconfig is
::
 
<connectionStrings>
  <add name="SGUConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\uni.mdb" providerName="System.Data.OleDb"/>
 </connectionStrings>
please help me out... i can't find the error
 
if u get any soluation please inform mailto:me..saroop.trivedi@gmail.com - me..saroop.trivedi@gmail.com


-------------
reply me on my mail id:saroop.trivedi@gmail.com.
crystal report help.



Replies:
Posted By: BrianBischof
Date Posted: 26 Jan 2011 at 9:54am
First off, put the call to reportconnection() in the Page_Init() event, not Page_Load(). Prior to .NET 2005 it was okay to put it in Page_Load(). But now they changed how memory is managed and this can give you random errors depending upon the state of the CrystalReportViewer's memory. Putting it in Page_Init() is safe all the time.

Secondly, I would do is remove the code:
CrystalReportViewer1.DataBind();

I would also remove the RefreshReport() call b/c it refreshes itself automatically when you assign the report object to it. But it doesn't hurt to have it. Either way, definitely get rid of the .DataBind() call.

Hopefully these changes will get your application back to working.

Brian


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window