Solved

Form.shown Event speed

Posted on 2014-11-10
11
116 Views
Last Modified: 2014-12-04
Hi,

I've moved all my code from my startup form form_load event to the form_shown event because I was having problem with crystal reports in other forms giving me a  "crystal report print Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Every time I was printing or exporting a report

This has fixed the crystal reports issues I was having, the only thing is that now the startup form seems take more time to load, it seems to start "stuck" and then loads everything.

Though personally I don't mind the delay, some users might and I was wondering if there was a way to speed it up a little being that it is in the form_shown event?

Thank you,
0
Comment
Question by:FCapo
  • 5
  • 5
11 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 40433845
Are you rendering the report when the form is loaded?

mlmcc
0
 
LVL 18

Expert Comment

by:vasto
ID: 40433872
You should create a separate thread and load the report there. This will not slow the form
0
 

Author Comment

by:FCapo
ID: 40435138
Hi, the following code is in the form_shown event, I have no reports on this form, this is simply my start up form, the reports are located in other forms in my app;

I have no idea why but if I keep the following code in the form_load event it crashes my application when I try to open the forms that do have reports with "crystal report print Attempted to read or write protected memory. This is often an indication that other memory is corrupt." :

having it in the Form1_Shown event seems to solve the crash but it creates a delay when the start up form is first shown

Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown

        clientData = New Clients
        cliDataSet = clientData.getCliDataSet
        cliBindingSource = New BindingSource

        clientDataExtra = New clientsExtra
        clidatasetExtra = clientDataExtra.getCliDataSet
        cliBindingSourceExtra = New BindingSource

        rectAccessData = New ClientsAccess
        recAccDataSet = rectAccessData.getRecDataSet
        AccessBindingsource = New BindingSource

        clientAccessData = New ClientsAccess
        cliAccDataSet = clientAccessData.getrelateddata
        cliAccessBindingsource = New BindingSource

        timeData = New timesheet
        timeDataSet = timeData.getTimesheetHoursDataSet
        timeBindingSource = New BindingSource

        timeData1 = New timesheet
        timeDataSet1 = timeData1.getTimesheetHoursDataSet2
        timeBindingSource1 = New BindingSource

        budgetData = New ClientsAccess
        budgetdataset = budgetData.getBudget
        budgetBindingsource = New BindingSource

        With cliAccessBindingsource
            .DataSource = cliAccDataSet
            .DataMember = "projets"
        End With

        With budgetBindingsource
            .DataSource = budgetdataset
            .DataMember = "budget"
        End With

        With timeBindingSource
            .DataSource = timeDataSet
            .DataMember = "FeuillesDeTemps"
            .Sort = "ID"
        End With

        With timeBindingSource1
            .DataSource = timeDataSet1
            .DataMember = "FeuillesDeTemps"
            .Sort = "ID"
        End With

        With AccessBindingsource
            .DataSource = recAccDataSet
            .DataMember = "recevable"
        End With

        With cliBindingSource
            .DataSource = cliDataSet
            .DataMember = "DataTable"
            .Sort = "sName"
        End With

        With cliBindingSourceExtra
            .DataSource = clidatasetExtra
            .DataMember = "DataTable1"
        End With

        With cliCbx
            .DataSource = cliBindingSource
            .DataBindings.Add("text", cliBindingSource, "sName", False, DataSourceUpdateMode.Never)
            .DisplayMember = "sName"
        End With

        With extraCbx
            .DataSource = cliBindingSourceExtra
            .DataBindings.Add("text", cliBindingSourceExtra, "lCusId", False, DataSourceUpdateMode.Never)
            .DisplayMember = "lCusId"
        End With

        DataGridView1.DataSource = cliBindingSource

        For i = 0 To DataGridView1.Columns.Count - 1
            If i = 1 Then
            Else
                DataGridView1.Columns(i).Visible = False
            End If
        Next

        DataGridView1.Columns(1).HeaderText = "Nom du client"
        DataGridView1.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill

        SimpleId.DataBindings.Add("text", cliBindingSource, "lId")
        cliSimplyExtra.DataBindings.Add("text", cliBindingSourceExtra, "lCusId")

        cliRue1.DataBindings.Add("text", cliBindingSource, "sStreet1")
        cliRue2.DataBindings.Add("text", cliBindingSource, "sStreet2")
        cliVille.DataBindings.Add("text", cliBindingSource, "sCity")
        cliPrv.DataBindings.Add("text", cliBindingSource, "sProvState")
        cliCode.DataBindings.Add("text", cliBindingSource, "sPostalZip")
        cliCourriel.DataBindings.Add("text", cliBindingSource, "sEmail")
        CliTxt.DataBindings.Add("text", cliBindingSource, "sCntcName")
        cliTelBur.DataBindings.Add("text", cliBindingSource, "sPhone1")
        cliTelCell.DataBindings.Add("text", cliBindingSource, "sPhone2")
        cliFax.DataBindings.Add("text", cliBindingSource, "sFax")
        cliTelDom.DataBindings.Add("text", cliBindingSourceExtra, "sUsrDfnd1")

        TextBox1.Select()

        If My.Settings.recevReminders = "yes" Then
            checkpopupsettings()
        End If

        If My.Settings.timesheetReminders = "yes" Then
            My.Settings.timesheetId = timeDataSet.FeuillesDeTemps.Compute("max(ID)", "")
            startEmailTimer()
            checktimersheetTimer()
        End If

        TabControl1.SelectedIndex = 1
        TabControl1.SelectedIndex = 0

    End Sub

Open in new window

0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:FCapo
ID: 40437831
Any ideas?

Why does having my code in the startup Form1_Shown instead of Form1_load event impact crystal reports being able to print or export in another form?
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 40437860
I have no idea.

Most likely it is because of when the event fires in relation to when the report loads

mlmcc
0
 

Author Comment

by:FCapo
ID: 40438769
After looking further,

I've come to the conclusion that it has to do with the Access format of my database, which is .ACCDB

I've tried converting it to the standard .MDB version and updating it in my datasets, afterwards crystal report was no longer giving me this error when printing or exporting;

I've attached a screenshot of how Crystal Reports is set to connect to my database, when switching over from Provider=Microsoft.ACE.OLEDB.12.0  to Provider=Microsoft.Jet.OLEDB.4.0 it seemed to no longer give me this error.

I rather keep the .ACCDB since I have a few apps connecting to it, hopefully you can look at the screencapture and there may be a different way to connect to it that wouldn't provoke this error?

Thank you
screen.png
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 40439114
What version of Crystal?

DId you download the Office database connectors?

mlmcc
0
 

Author Comment

by:FCapo
ID: 40440130
I have the full crystal report version 11.5.0.313 running with visual studio 2010 and the crystal reports Support Pack 12 (v.13.0.12.1494).

Yes I believe I have the right Office database connectors, I only get these issues when crystal reports sees more than one connection is made to the .ACCDB database, using the JET connection crystal reports doesn't give me any issues...
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 500 total points
ID: 40440606
CR XI R2 (v11.5.x.xxx) was built for .Net 2.0.  Are you running in a later .Net framework?

You probably want to change the reports to use the .Net version

mlmcc
0
 

Author Comment

by:FCapo
ID: 40440921
I'm running .net framework 4, How can I about changing the report to use the .Net version? Is there a setting I can change somewhere?

Thank you
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 500 total points
ID: 40441463
You should be able to install the CR for .Net then import the report into the application and save it.

mlmcc
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

774 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question