Announcements
 Crystal Reports Forum : General Information : Announcements
Message Icon Topic: my crystal report not work online Post Reply Post New Topic
Author Message
sarooptrivedi
Newbie
Newbie
Avatar

Joined: 18 Jun 2008
Online Status: Offline
Posts: 10
Quote sarooptrivedi Replybullet Topic: my crystal report not work online
    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 me..saroop.trivedi@gmail.com
reply me on my mail id:saroop.trivedi@gmail.com.
crystal report help.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.