Solved

Form.shown Event speed

Posted on 2014-11-10
11
121 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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