Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi all
Help!!!!!!
I am using Microsoft Reports for reporting.I have a problem when I view a report in my application all forms of application is opened slowly , but when I opened any form before viewing report it opens normally .
Thanks.
 
Here is the code
-------------////////////////////////
------------////////////////////////
Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
Dim dtPrev As New DataTable
 
pgpShow.Visible = True
btnClose.Enabled = False
btnPreview.Enabled = False
lblWait.Visible = True
cmbReportName.Enabled = False
chkAllReport.Enabled = False
ChkLstReports.Enabled = False
dtpFrom.Enabled = False
dtpTo.Enabled = False
CheckForIllegalCrossThreadCalls = False
If (con_con.State <> ConnectionState.Open) Then
con_con.ConnectionString = ConnectionStr
Try
con_con.Open()
Catch ex As Exception
End Try
End If
Dim Image As Image = My.Resources._86
Dim memImage As New System.IO.MemoryStream
Dim bytImage() As Byte
Image.Save(memImage, Image.RawFormat)
bytImage = memImage.GetBuffer()
 
If FrmMain.DSOptions.Tables(0).Rows(0).Item("logo") Is DBNull.Value Then
pic = bytImage
Else
pic = FrmMain.DSOptions.Tables(0).Rows(0).Item("logo")
End If
param = New List(Of ReportParameter)
Dim str1 As String
str1 = System.Convert.ToBase64String(pic)
param.Add(New ReportParameter("Path", str1))
''''''/////////////
param.Add(New ReportParameter("CompanyName", "Company: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("ArName").ToString()))
param.Add(New ReportParameter("Address", "Address: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("ArAddress").ToString()))
param.Add(New ReportParameter("Phone", "Phone: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("Phone").ToString()))
param.Add(New ReportParameter("Fax", "Fax: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("Fax").ToString()))
param.Add(New ReportParameter("DFrom", "From: " & dtpFrom.Text))
param.Add(New ReportParameter("DTo", "To: " & dtpTo.Text))
If chkRptName.Checked Then
If txtRptName.Text.Trim <> "" Then
param.Add(New ReportParameter("RptName", txtRptName.Text))
Else
If ChkLstReports.SelectedIndex <> -1 Then
param.Add(New ReportParameter("RptName", ChkLstReports.Items.Item(ChkLstReports.SelectedIndex).ToString))
Else
param.Add(New ReportParameter("RptName", " "))
End If
End If
Else
param.Add(New ReportParameter("RptName", " "))
End If
 

If ChkLstReports.CheckedItems.Count = 0 Then
MessageBox.Show("Choose report name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)

lblWait.Visible = False
pgpShow.Value = 0
btnClose.Enabled = True
btnPreview.Enabled = True
pgpShow.Visible = False
cmbReportName.Enabled = True
chkAllReport.Enabled = True
ChkLstReports.Enabled = True
dtpFrom.Enabled = True
dtpTo.Enabled = True
Exit Sub
End If
If cmbReportName.SelectedIndex = 2 Then
If ChkLstReports.CheckedItems.Count = 0 Or ChkLstReports.CheckedItems.Count > 1 Then
MessageBox.Show("Choose one report only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)

lblWait.Visible = False
pgpShow.Value = 0
btnClose.Enabled = True
btnPreview.Enabled = True
pgpShow.Visible = False
cmbReportName.Enabled = True
chkAllReport.Enabled = True
ChkLstReports.Enabled = True
dtpFrom.Enabled = True
dtpTo.Enabled = True
Exit Sub
End If
sReportID = ""
For j As Integer = 0 To ChkLstReports.CheckedItems.Count - 1
If sReportID = "" Then
sReportID = "'" & ChkLstReports.IDItems(ChkLstReports.CheckedIndices.Item(j)) & "'"
Else
sReportID &= ",'" & ChkLstReports.IDItems(ChkLstReports.CheckedIndices.Item(j)) & "'"
End If
Next
''dtPrev = OceanDB.ExecuteDataTable(FrmMain.con, CommandType.Text, " Select * From TotalsAcc where ReportID In (" & sReportID & ")")
'''' balance
Dim threadProg As New Threading.Thread(AddressOf BalanceRep)
'Threading.Thread
threadProg.ApartmentState = Threading.ApartmentState.STA
threadProg.Start()
While threadProg.IsAlive
If pgpShow.Value = 100 Then
pgpShow.Value = 0
End If
pgpShow.Value += pgpShow.Step
Threading.Thread.Sleep(100)
Application.DoEvents()
 
End While
 
'Application.DoEvents()
'BalanceRep()
Else
sReportID = ""
For j As Integer = 0 To ChkLstReports.CheckedItems.Count - 1
If sReportID = "" Then
sReportID = ChkLstReports.IDItems(ChkLstReports.CheckedIndices.Item(j))
Else
sReportID &= "," & ChkLstReports.IDItems(ChkLstReports.CheckedIndices.Item(j))
End If
Next
 
''dtPrev = OceanDB.ExecuteDataTable(FrmMain.con, CommandType.Text, " Select * From Reports where IDR In (" & sReportID & ")")
''''''''''///////////////////
If cmbReportName.SelectedIndex = 1 Then
 
Dim threadProg As New Threading.Thread(AddressOf FinanceRep)
'Threading.Thread
 
threadProg.Start()
While threadProg.IsAlive
If pgpShow.Value = 100 Then
pgpShow.Value = 0
End If
pgpShow.Value += pgpShow.Step
Threading.Thread.Sleep(100)
Application.DoEvents()
End While
''threadProg.MemoryBarrier()
ElseIf cmbReportName.SelectedIndex = 0 Then
'''''''''''/////////////////////
Dim threadProg As New Threading.Thread(AddressOf ExpenseRep)
'Threading.Thread
 
threadProg.Start()
While threadProg.IsAlive
If pgpShow.Value = 100 Then
pgpShow.Value = 0
End If
pgpShow.Value += pgpShow.Step
Threading.Thread.Sleep(100)
Application.DoEvents()
End While
End If
End If

' EndWait()
End Sub
 
'''''///////////////////////////
Private Sub FinanceRep()
If (con_con.State <> ConnectionState.Open) Then
con_con.ConnectionString = ConnectionStr
Try
con_con.Open()
Catch ex As Exception
End Try
End If
dsg.Clear()
Dim dtPrev As New DataTable
dtPrev = OceanDB.ExecuteDataTable(con_con, CommandType.Text, " Select * From Reports where IDR In (" & sReportID & ")")
Dim dsr As New DataSet1
dsr.Tables("DataTable1").Columns("value").DataType = Type.GetType("System.Decimal")
For i As Integer = 0 To dtPrev.Rows.Count - 1
For j As Integer = 0 To dtPrev.Rows(i)("reportvalue").Split("*").Length - 1
If (con_con.State <> ConnectionState.Open) Then
con_con.ConnectionString = ConnectionStr
Try
con_con.Open()
Catch ex As Exception
End Try
End If
If dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(0) = "" Then
Dim execc As New SqlDataAdapter("exec prcReport_MainLedgerAnA @parentcode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(1) & "',@fromcode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(2) & "',@tocode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(3) & "',@startDate='" & dtpFrom.Text & "',@endDate='" & dtpTo.Text & "',@IsPost=1", con_con)
execc.Fill(dsg)
' execc.Fill(dsr, "datatable1")
Else
Dim execc As New SqlDataAdapter("exec prcReport_MainLedgerAnA @costcenter='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(0) & "',@parentcode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(1) & "',@fromcode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(2) & "',@tocode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(3) & "',@startDate='" & dtpFrom.Text & "',@endDate='" & dtpTo.Text & "',@IsPost=1", con_con)
execc.Fill(dsg)
' execc.Fill(dsr, "datatable1")
End If
Next
Next
''If dsr.Tables("DataTable1").Rows.Count = 0 Then
If dsg.Tables(0).Rows.Count = 0 Then
If UserLanguage = LanguageSetting.Arabic Then
CMessageBox.Show("لا توجد بيانات في هذه الفترة", "انتبه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading)
ElseIf UserLanguage = LanguageSetting.English Then
MessageBox.Show("No data exists at this interval", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
EndWait()
Exit Sub
End If
''Dim pic As Byte()
''pic = FrmMain.DSOptions.Tables(0).Rows(0).Item("logo")
''Dim param As New List(Of ReportParameter)
''Dim str1 As String
''str1 = System.Convert.ToBase64String(pic)
previewDyn = New previewDynamic
previewDyn.ReportViewer1.LocalReport.ReportPath = Application.StartupPath & "\OceanReports\FinanceRep.rdlc" '''" & cmbReportName.Text & "
previewDyn.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
previewDyn.ReportViewer1.LocalReport.DataSources.Clear()
previewDyn.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_DataTable1", dsg.Tables(0))) ''dsr.Tables("DataTable1")))
 
''param.Add(New ReportParameter("Path", str1))
 
''''''''/////////////
''param.Add(New ReportParameter("CompanyName", "Company: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("ArName").ToString()))
''param.Add(New ReportParameter("Address", "Address: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("ArAddress").ToString()))
''param.Add(New ReportParameter("Phone", "Phone: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("Phone").ToString()))
''param.Add(New ReportParameter("Fax", "Fax: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("Fax").ToString()))
''param.Add(New ReportParameter("DFrom", "From: " & dtpFrom.Text))
''param.Add(New ReportParameter("DTo", "To: " & dtpTo.Text))
''//////////////
 
previewDyn.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
previewDyn.ReportViewer1.LocalReport.SetParameters(param)
previewDyn.ReportViewer1.RefreshReport()
previewDyn.ShowDialog(Me)
EndWait()
End Sub
Private Sub ExpenseRep()
If (con_con.State <> ConnectionState.Open) Then
con_con.ConnectionString = ConnectionStr
Try
con_con.Open()
Catch ex As Exception
End Try
End If
dsg.Clear()
Dim dtPrev As New DataTable
dtPrev = OceanDB.ExecuteDataTable(con_con, CommandType.Text, " Select * From Reports where IDR In (" & sReportID & ")")
Dim dsr As New DataSet1
dsr.Tables("DataTable1").Columns("value").DataType = Type.GetType("System.Decimal")
For i As Integer = 0 To dtPrev.Rows.Count - 1
For j As Integer = 0 To dtPrev.Rows(i)("reportvalue").Split("*").Length - 1
If (con_con.State <> ConnectionState.Open) Then
con_con.ConnectionString = ConnectionStr
Try
con_con.Open()
Catch ex As Exception
End Try
End If
If dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(0) = "" Then
Dim execc As New SqlDataAdapter("exec prcReport_MainLedgerAnA @parentcode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(1) & "',@fromcode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(2) & "',@tocode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(3) & "',@startDate='" & dtpFrom.Text & "',@endDate='" & dtpTo.Text & "',@IsPost=1", con_con)
execc.Fill(dsg)
' execc.Fill(dsr, "datatable1")
Else
Dim execc As New SqlDataAdapter("exec prcReport_MainLedgerAnA @costcenter='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(0) & "',@parentcode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(1) & "',@fromcode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(2) & "',@tocode='" & dtPrev.Rows(i)("reportvalue").Split("*")(j).ToString.Split("\").GetValue(3) & "',@startDate='" & dtpFrom.Text & "',@endDate='" & dtpTo.Text & "',@IsPost=1", con_con)
execc.Fill(dsg)
' execc.Fill(dsr, "datatable1")
End If
Next
Next
'If dsr.Tables("DataTable1").Rows.Count = 0 Then
If dsg.Tables(0).Rows.Count = 0 Then
If UserLanguage = LanguageSetting.Arabic Then
CMessageBox.Show("لا توجد بيانات في هذه الفترة", "انتبه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading)
ElseIf UserLanguage = LanguageSetting.English Then
MessageBox.Show("No data exists at this interval", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
EndWait()
Exit Sub
End If
Dim pra As New Microsoft.Reporting.WebForms.ReportParameter
Dim rp As New Microsoft.Reporting.WebForms.ReportParameter("textbox1", "dfdf")
''Dim pic As Byte()
''pic = FrmMain.DSOptions.Tables(0).Rows(0).Item("logo")
''Dim param As New List(Of ReportParameter)
''Dim str1 As String
''str1 = System.Convert.ToBase64String(pic)
previewDyn = New previewDynamic
 

previewDyn.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
 
'pra.Name = "textbox1"
'pra.Values.Add("asdasd")
previewDyn.ReportViewer1.LocalReport.ReportPath = Application.StartupPath & "\OceanReports\ExpenseAnalysis.rdlc" ''' cmboBox.text &"" cmbReportName.Text &
previewDyn.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
'preview.ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WinForms.ReportParameter() {rp})
previewDyn.ReportViewer1.LocalReport.DataSources.Clear()
previewDyn.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_DataTable1", dsg.Tables(0))) ''dsr.Tables("DataTable1")))
 
''param.Add(New ReportParameter("Path", str1))
''''''''/////////////
''param.Add(New ReportParameter("CompanyName", "Company: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("ArName").ToString()))
''param.Add(New ReportParameter("Address", "Address: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("ArAddress").ToString()))
''param.Add(New ReportParameter("Phone", "Phone: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("Phone").ToString()))
''param.Add(New ReportParameter("Fax", "Fax: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("Fax").ToString()))
''param.Add(New ReportParameter("DFrom", "From: " & dtpFrom.Text))
''param.Add(New ReportParameter("DTo", "To: " & dtpTo.Text))
''//////////////
previewDyn.ReportViewer1.LocalReport.SetParameters(param)
previewDyn.ReportViewer1.RefreshReport()
previewDyn.ShowDialog(Me)
EndWait()
End Sub
Private Sub BalanceRep()
If (con_con.State <> ConnectionState.Open) Then
con_con.ConnectionString = ConnectionStr
Try
con_con.Open()
Catch ex As Exception
End Try
End If
dsg.Clear()
'Application.DoEvents()
Dim dsr As New DataSet1
dsr.Tables("DataTable1").Columns("value").DataType = Type.GetType("System.Decimal")
'Application.DoEvents()
Dim execc As New SqlDataAdapter("exec Prc_AccReport " & sReportID & ",'" & dtpFrom.Text & "','" & dtpTo.Text & "' ", con_con)
execc.SelectCommand.CommandTimeout = 4000000
execc.Fill(dsg)
' execc.Fill(dsr, "datatable1")
''If dsr.Tables("DataTable1").Rows.Count = 0 Then
If dsg.Tables(0).Rows.Count = 0 Then
If UserLanguage = LanguageSetting.Arabic Then
CMessageBox.Show("لا توجد بيانات في هذه الفترة", "انتبه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading)
ElseIf UserLanguage = LanguageSetting.English Then
MessageBox.Show("No data exists at this interval", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
EndWait()
Exit Sub
End If
''Dim pic As Byte()
''pic = FrmMain.DSOptions.Tables(0).Rows(0).Item("logo")
''Dim param As New List(Of ReportParameter)
''Dim str1 As String
''str1 = System.Convert.ToBase64String(pic)
previewDyn = New previewDynamic
previewDyn.ReportViewer1.LocalReport.ReportPath = Application.StartupPath & "\OceanReports\Balancesh.rdlc" '''" & cmbReportName.Text & "
previewDyn.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
previewDyn.ReportViewer1.LocalReport.DataSources.Clear()
previewDyn.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_DataTable1", dsg.Tables(0))) ''dsr.Tables("DataTable1")))
''param.Add(New ReportParameter("Path", str1))
 
''''''''/////////////
''param.Add(New ReportParameter("CompanyName", "Company: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("ArName").ToString()))
''param.Add(New ReportParameter("Address", "Address: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("ArAddress").ToString()))
''param.Add(New ReportParameter("Phone", "Phone: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("Phone").ToString()))
''param.Add(New ReportParameter("Fax", "Fax: " & FrmMain.DSOptions.Tables(0).Rows(0).Item("Fax").ToString()))
''param.Add(New ReportParameter("DFrom", "From: " & dtpFrom.Text))
''param.Add(New ReportParameter("DTo", "To: " & dtpTo.Text))
previewDyn.ReportViewer1.LocalReport.SetParameters(param)
''//////////////
previewDyn.ReportViewer1.RefreshReport()
previewDyn.ShowDialog(Me)
EndWait()
 
'''''''''//////////////// Balance Sheeeeeeeeeeeet
End Sub
Posted 13-Jun-11 22:48pm
Edited 14-Jun-11 22:06pm
v3
Comments
thatraja at 14-Jun-11 7:59am
   
Share the code of the report. BTW include that in your question.
Kschuler at 14-Jun-11 11:01am
   
Also include any error messages that you are getting.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,614
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 15 Jun 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100