Hi Experts,,
ToReportInASP.Net, I am using SAPCrystalReport. Whythe Printbutton on theToolbardoes not work?so I can notprint reportsthatshow.
Is it becausein the SubPage_Load I use thecommand"If NotPage.IsPostBackThen"
If Ido notuse, If NotPage.IsPostBack Then, latercode thatinsideSub Page_Load(senderAs Object, eAsEventArgs) will be executedrepeatedly. So Istopped it.so justexecutedonce, when WebFormis loaded atfirst.
For more details, belowIshow thesourcecodethat I use.
Sub Page_Load(sender As Object, e As EventArgs)
If Not Page.IsPostBack Then
Try
myConnection = New MySqlConnection(".....;")
cmd.CommandText = "insert into table1(...) select ... from tbtemp where KodeKantorCabang='" & Session("KodeKantorCabang") & "'"
cmd.CommandType = CommandType.Text
cmd.Connection = myConnection
myConnection.Open()
cmd.ExecuteNonQuery()
strSql = "select ... from tbtemp WHERE KodeKantorCabang='" & Session("KodeKantorCabang") & "'"
myDataAdapter = New MySqlDataAdapter(strSql, myConnection)
myDataAdapter.Fill(dsK, "DTKwitansi")
If dsK.Tables("DTKwitansi").Rows.Count > 0 Then
rpt = New crKwitansi
rpt.SetDataSource(dsK)
Dim crPFDs As ParameterFieldDefinitions
Dim crPFD As ParameterFieldDefinition
Dim crPVs As New ParameterValues
Dim crPDV As New ParameterDiscreteValue
crPDV.Value = Session("NamaUser").ToString
crPFDs = rpt.DataDefinition.ParameterFields
crPFD = crPFDs.Item("pNamaUser")
crPVs.Clear()
crPVs.Add(crPDV)
crPFD.ApplyCurrentValues(crPVs)
CrystalReportViewer1.ReportSource = rpt
cmd.CommandText = "delete from tbtemp where KodeKantorCabang='" & Session("KodeKantorCabang") & "'"
cmd.CommandType = CommandType.Text
cmd.Connection = myConnection
cmd.ExecuteNonQuery()
myConnection.Close()
End If
Catch ex As MySqlException
Response.Write("My Sql Exception: " & ex.Message)
End Try
End If
End Sub