Click here to Skip to main content
15,886,873 members

Microsoft Reports problem

hamdy_2000 asked:

Open original thread
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
Tags: Visual Basic

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900