Abdul Rouf
New member
- Joined
- May 27, 2010
- Messages
- 1
- Programming Experience
- Beginner
I have tried my best but failed so i have decided to discuss with u all about this matter.
when i run Given below code on my current system it's OK but when i install this on my client machine then it gives my a window during call Print button event that ask for User Name and Password which are filled according to my setting.
But there is no database name that is given by me. Any one can help me about this problem.
Thanx for this.
Private Sub btn_PrintOC_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_PrintOC.Click
frm_Reports.MdiParent = frm_Main
frm_Reports.CRV.ReportSource = Set_rpt_W_2PM( "OCBasicInfo.rpt" , "@OC_No" , "@Proce_TypePRT" , "@Proce_TypeEMB" , "@Proce_TypeFNG" , "@Proce_TypeSPCT" , lbl_OcNumber.Text)
frm_Reports.Show()
frm_Reports.WindowState = FormWindowState.Maximized
End Sub
Public Function Set_rpt_W_2PM( ByVal rptName As String , ByVal PMName1 As String , ByVal PMName2 As String , ByVal PMName3 As String , ByVal PMName4 As String , ByVal PMName5 As String , ByVal PMvalue As String ) As ReportDocument
Dim rpt1 As New ReportDocument
Dim rptPath As String = Application.StartupPath & "\" & rptName
rpt1.Load(rptPath)
GETSERVERNAMEANDDATABASENAME(rpt1, "dbTemp" )
Dim paramFs1 As ParameterFieldDefinitions
paramFs1 = rpt1.DataDefinition.ParameterFields
Dim paramF As ParameterFieldDefinition = paramFs1(PMName1)
Dim paramF2 As ParameterFieldDefinition = paramFs1(PMName2)
Dim paramF3 As ParameterFieldDefinition = paramFs1(PMName3)
Dim paramF4 As ParameterFieldDefinition = paramFs1(PMName4)
Dim paramF5 As ParameterFieldDefinition = paramFs1(PMName5)
Dim pvalues As ParameterValues = New ParameterValues
Dim pvalues2 As ParameterValues = New ParameterValues
Dim pvalues3 As ParameterValues = New ParameterValues
Dim pvalues4 As ParameterValues = New ParameterValues
Dim pvalues5 As ParameterValues = New ParameterValues
Dim dvalue As New ParameterDiscreteValue
Dim dvalue2 As New ParameterDiscreteValue
Dim dvalue3 As New ParameterDiscreteValue
Dim dvalue4 As New ParameterDiscreteValue
Dim dvalue5 As New ParameterDiscreteValue
Dim defvalues2 As New ParameterValues
Dim defvalues3 As New ParameterValues
Dim defvalues4 As New ParameterValues
Dim defvalues5 As New ParameterValues
defvalues2 = paramF2.DefaultValues
defvalues3 = paramF3.DefaultValues
defvalues4 = paramF4.DefaultValues
defvalues5 = paramF5.DefaultValues
dvalue.Value = PMvalue
Dim pdv2 As ParameterDiscreteValue = CType (defvalues2(0), ParameterDiscreteValue)
Dim pdv3 As ParameterDiscreteValue = CType (defvalues3(0), ParameterDiscreteValue)
Dim pdv4 As ParameterDiscreteValue = CType (defvalues4(0), ParameterDiscreteValue)
Dim pdv5 As ParameterDiscreteValue = CType (defvalues5(0), ParameterDiscreteValue)
dvalue2.Value = pdv2.Value
dvalue3.Value = pdv3.Value
dvalue4.Value = pdv4.Value
dvalue5.Value = pdv5.Value
pvalues.Add(dvalue)
pvalues2.Add(dvalue2)
pvalues3.Add(dvalue3)
pvalues4.Add(dvalue4)
pvalues5.Add(dvalue5)
paramF.ApplyCurrentValues(pvalues)
paramF2.ApplyCurrentValues(pvalues2)
paramF3.ApplyCurrentValues(pvalues3)
paramF4.ApplyCurrentValues(pvalues4)
paramF5.ApplyCurrentValues(pvalues5)
Return rpt1
End Function
Public Sub GETSERVERNAMEANDDATABASENAME( ByVal rpt As Object , ByVal DATABASENAME As String ) ', Optional ByVal PASSWORD As String = "", Optional ByVal USER As String = "")
Dim I As Integer
Dim TBL1 As New CrystalDecisions.Shared.TableLogOnInfo
TBL1.ConnectionInfo.ServerName = "it-2\SQLEXPRESS"
TBL1.ConnectionInfo.DatabaseName = DATABASENAME
TBL1.ConnectionInfo.Password = "alflah"
TBL1.ConnectionInfo.UserID = "sa"
For I = 0 To rpt.Database.Tables.Count – 1
rpt.Database.Tables(I).ApplyLogOnInfo(TBL1)
Next I
End Sub
when i run Given below code on my current system it's OK but when i install this on my client machine then it gives my a window during call Print button event that ask for User Name and Password which are filled according to my setting.
But there is no database name that is given by me. Any one can help me about this problem.
Thanx for this.
Private Sub btn_PrintOC_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_PrintOC.Click
frm_Reports.MdiParent = frm_Main
frm_Reports.CRV.ReportSource = Set_rpt_W_2PM( "OCBasicInfo.rpt" , "@OC_No" , "@Proce_TypePRT" , "@Proce_TypeEMB" , "@Proce_TypeFNG" , "@Proce_TypeSPCT" , lbl_OcNumber.Text)
frm_Reports.Show()
frm_Reports.WindowState = FormWindowState.Maximized
End Sub
Public Function Set_rpt_W_2PM( ByVal rptName As String , ByVal PMName1 As String , ByVal PMName2 As String , ByVal PMName3 As String , ByVal PMName4 As String , ByVal PMName5 As String , ByVal PMvalue As String ) As ReportDocument
Dim rpt1 As New ReportDocument
Dim rptPath As String = Application.StartupPath & "\" & rptName
rpt1.Load(rptPath)
GETSERVERNAMEANDDATABASENAME(rpt1, "dbTemp" )
Dim paramFs1 As ParameterFieldDefinitions
paramFs1 = rpt1.DataDefinition.ParameterFields
Dim paramF As ParameterFieldDefinition = paramFs1(PMName1)
Dim paramF2 As ParameterFieldDefinition = paramFs1(PMName2)
Dim paramF3 As ParameterFieldDefinition = paramFs1(PMName3)
Dim paramF4 As ParameterFieldDefinition = paramFs1(PMName4)
Dim paramF5 As ParameterFieldDefinition = paramFs1(PMName5)
Dim pvalues As ParameterValues = New ParameterValues
Dim pvalues2 As ParameterValues = New ParameterValues
Dim pvalues3 As ParameterValues = New ParameterValues
Dim pvalues4 As ParameterValues = New ParameterValues
Dim pvalues5 As ParameterValues = New ParameterValues
Dim dvalue As New ParameterDiscreteValue
Dim dvalue2 As New ParameterDiscreteValue
Dim dvalue3 As New ParameterDiscreteValue
Dim dvalue4 As New ParameterDiscreteValue
Dim dvalue5 As New ParameterDiscreteValue
Dim defvalues2 As New ParameterValues
Dim defvalues3 As New ParameterValues
Dim defvalues4 As New ParameterValues
Dim defvalues5 As New ParameterValues
defvalues2 = paramF2.DefaultValues
defvalues3 = paramF3.DefaultValues
defvalues4 = paramF4.DefaultValues
defvalues5 = paramF5.DefaultValues
dvalue.Value = PMvalue
Dim pdv2 As ParameterDiscreteValue = CType (defvalues2(0), ParameterDiscreteValue)
Dim pdv3 As ParameterDiscreteValue = CType (defvalues3(0), ParameterDiscreteValue)
Dim pdv4 As ParameterDiscreteValue = CType (defvalues4(0), ParameterDiscreteValue)
Dim pdv5 As ParameterDiscreteValue = CType (defvalues5(0), ParameterDiscreteValue)
dvalue2.Value = pdv2.Value
dvalue3.Value = pdv3.Value
dvalue4.Value = pdv4.Value
dvalue5.Value = pdv5.Value
pvalues.Add(dvalue)
pvalues2.Add(dvalue2)
pvalues3.Add(dvalue3)
pvalues4.Add(dvalue4)
pvalues5.Add(dvalue5)
paramF.ApplyCurrentValues(pvalues)
paramF2.ApplyCurrentValues(pvalues2)
paramF3.ApplyCurrentValues(pvalues3)
paramF4.ApplyCurrentValues(pvalues4)
paramF5.ApplyCurrentValues(pvalues5)
Return rpt1
End Function
Public Sub GETSERVERNAMEANDDATABASENAME( ByVal rpt As Object , ByVal DATABASENAME As String ) ', Optional ByVal PASSWORD As String = "", Optional ByVal USER As String = "")
Dim I As Integer
Dim TBL1 As New CrystalDecisions.Shared.TableLogOnInfo
TBL1.ConnectionInfo.ServerName = "it-2\SQLEXPRESS"
TBL1.ConnectionInfo.DatabaseName = DATABASENAME
TBL1.ConnectionInfo.Password = "alflah"
TBL1.ConnectionInfo.UserID = "sa"
For I = 0 To rpt.Database.Tables.Count – 1
rpt.Database.Tables(I).ApplyLogOnInfo(TBL1)
Next I
End Sub