Ayuda con Crystal Report 9
Mi problema es que he generado un report y un subreport, con crystal report 9, y cuando abro el report desde visual me da un error.
Bueno ahora te voy a poner el código que utilizo desde visual y el error que me da exactamente.
Antes de este código yo llamo a este formulario desde otro que es desde donde le pasa los parámetros que necesito.
Option Explicit
Public intNumeroPedido As Long
Private crApp As New CRAXDRT.Application
Private crReport As New CRAXDRT.Report
Private crSubReport As New CRAXDRT.Report
Private prmPedidoNum As String
Private prmCliente As String
Private prmDireccion As String
Private prmCP As String
Private prmLocalidad As String
Private prmProvincia As String
Private mflgContinuar As Boolean
Private Sub Form_Resize()
CRViewer.Top = 0
CRViewer.Left = 0
CRViewer.Height = ScaleHeight
CRViewer.Width = ScaleWidth
End Sub
Private Sub CRViewer_PrintButtonClicked(UseDefault As Boolean)
crReport.PrinterSetup Me.hwnd
End Sub
Public Sub PasarParametros(sParam1 As String, sParam2 As String, _
sParam3 As String, sParam4 As String, _
sParam5 As String, sParam6 As String)
If sParam1 = "" Then
prmPedidoNum = ""
Else
prmPedidoNum = sParam1
End If
If sParam2 = "" Then
prmCliente = ""
Else
prmCliente = sParam2
End If
If sParam3 = "" Then
prmDireccion = ""
Else
prmDireccion = sParam3
End If
If sParam4 = "" Then
prmCP = ""
Else
prmCP = sParam4
End If
If sParam5 = "" Then
prmLocalidad = ""
Else
prmLocalidad = sParam5
End If
If sParam6 = "" Then
prmProvincia = ""
Else
prmProvincia = sParam6
End If
End Sub
Private Sub Form_Activate()
If Not mflgContinuar Then Unload Me
End Sub
Private Sub Form_Load()
Dim adoRS As ADODB.Recordset
Dim adoRS2 As ADODB.Recordset
Dim SQL As String
Dim SQL2 As String
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crParamDef As CRAXDRT.ParameterFieldDefinition
On Error GoTo ErrHandler
SQL = "SELECT dbo.tb_Productos.Nombre, dbo.tb_PedidosCliDetalle.Cantidad, dbo.tb_PedidosCliDetalle.PUnitario " & _
"FROM dbo.tb_PedidosCliDetalle INNER JOIN " & _
"dbo.tb_PedidosCli ON dbo.tb_PedidosCliDetalle.PedidoId = dbo.tb_PedidosCli.PedidoId INNER JOIN " & _
"dbo.tb_Productos ON dbo.tb_PedidosCliDetalle.ProductoId = dbo.tb_Productos.ProductoId INNER JOIN " & _
"dbo.tb_Cli ON dbo.tb_PedidosCli.CliId = dbo.tb_Cli.ClienteId " & _
"WHERE (dbo.tb_PedidosCli.PedidoId = " & intNumeroPedido & ")"
SQL2 = "SELECT dbo.tb_OF.Numero, dbo.tb_Productos.Nombre, dbo.tb_OF.CantidadPedida, dbo.tb_OF.CantidadFabricada, dbo.tb_OF.CantidadPendiente " & _
"FROM dbo.tb_Cli INNER JOIN " & _
"dbo.tb_OF ON dbo.tb_Cli.ClienteId = dbo.tb_OF.ClienteId INNER JOIN " & _
"dbo.tb_PedidosCli ON dbo.tb_OF.IdPedido = dbo.tb_PedidosCli.PedidoId AND dbo.tb_Cli.ClienteId = dbo.tb_PedidosCli.CliId INNER JOIN " & _
"dbo.tb_Productos ON dbo.tb_OF.ProductoId = dbo.tb_Productos.ProductoId " & _
"WHERE (dbo.tb_PedidosCli.PedidoId = " & intNumeroPedido & ")"
'Abrir el reporte
Screen.MousePointer = vbHourglass
mflgContinuar = True
Set crReport = crApp.OpenReport("c:\proyectos\PMP\Informes\PedidoCliente.rpt", 1)
Set crSubReport = crApp.OpenReport("c:\proyectos\PMP\Informes\OFPedidoCliente.rpt", 1)
' ********************* cargo el recordset
Set adoRS = ObtenerAdoRs(SQL)
Set adoRS2 = ObtenerAdoRs(SQL2)
crReport.Database.SetDataSource adoRS
crSubReport.Database.SetDataSource adoRS2
' *********************** cargo los parametros
Set crParamDefs = crReport.ParameterFields
For Each crParamDef In crParamDefs
Select Case crParamDef.ParameterFieldName
Case "pPedidoNum"
crParamDef.AddCurrentValue (prmPedidoNum)
Case "pCliente"
crParamDef.AddCurrentValue (prmCliente)
Case "pDireccion"
crParamDef.AddCurrentValue (prmDireccion)
Case "pCP"
crParamDef.AddCurrentValue (prmCP)
Case "pLocalidad"
crParamDef.AddCurrentValue (prmLocalidad)
Case "pProvincia"
crParamDef.AddCurrentValue (prmProvincia)
End Select
Next
' ejecuto el report
CRViewer.ReportSource = crReport
'CRViewer.ReportSource = crSubReport
CRViewer.ViewReport
Screen.MousePointer = vbDefault
Set crParamDefs = Nothing
Set crParamDef = Nothing
Exit Sub
ErrHandler:
If Err.Number = -2147206461 Then
MsgBox "El archivo de reporte no se encuentra, restáurelo de los discos de instalación", _
vbCritical + vbOKOnly
Else
MsgBox Err.Description, vbCritical + vbOKOnly
End If
mflgContinuar = False
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set crReport = Nothing
Set crSubReport = Nothing
Set crApp = Nothing
End Sub
ERROR:
Logon failed.
Details: ADO ERROR CODE: 0X80040E4D
Source: Microsoft OLEDB Provider for SQL SERVER
Description: Login failed for user 'sa'
SQL STATE: 42000
Native error: 18456
Bueno ahora te voy a poner el código que utilizo desde visual y el error que me da exactamente.
Antes de este código yo llamo a este formulario desde otro que es desde donde le pasa los parámetros que necesito.
Option Explicit
Public intNumeroPedido As Long
Private crApp As New CRAXDRT.Application
Private crReport As New CRAXDRT.Report
Private crSubReport As New CRAXDRT.Report
Private prmPedidoNum As String
Private prmCliente As String
Private prmDireccion As String
Private prmCP As String
Private prmLocalidad As String
Private prmProvincia As String
Private mflgContinuar As Boolean
Private Sub Form_Resize()
CRViewer.Top = 0
CRViewer.Left = 0
CRViewer.Height = ScaleHeight
CRViewer.Width = ScaleWidth
End Sub
Private Sub CRViewer_PrintButtonClicked(UseDefault As Boolean)
crReport.PrinterSetup Me.hwnd
End Sub
Public Sub PasarParametros(sParam1 As String, sParam2 As String, _
sParam3 As String, sParam4 As String, _
sParam5 As String, sParam6 As String)
If sParam1 = "" Then
prmPedidoNum = ""
Else
prmPedidoNum = sParam1
End If
If sParam2 = "" Then
prmCliente = ""
Else
prmCliente = sParam2
End If
If sParam3 = "" Then
prmDireccion = ""
Else
prmDireccion = sParam3
End If
If sParam4 = "" Then
prmCP = ""
Else
prmCP = sParam4
End If
If sParam5 = "" Then
prmLocalidad = ""
Else
prmLocalidad = sParam5
End If
If sParam6 = "" Then
prmProvincia = ""
Else
prmProvincia = sParam6
End If
End Sub
Private Sub Form_Activate()
If Not mflgContinuar Then Unload Me
End Sub
Private Sub Form_Load()
Dim adoRS As ADODB.Recordset
Dim adoRS2 As ADODB.Recordset
Dim SQL As String
Dim SQL2 As String
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crParamDef As CRAXDRT.ParameterFieldDefinition
On Error GoTo ErrHandler
SQL = "SELECT dbo.tb_Productos.Nombre, dbo.tb_PedidosCliDetalle.Cantidad, dbo.tb_PedidosCliDetalle.PUnitario " & _
"FROM dbo.tb_PedidosCliDetalle INNER JOIN " & _
"dbo.tb_PedidosCli ON dbo.tb_PedidosCliDetalle.PedidoId = dbo.tb_PedidosCli.PedidoId INNER JOIN " & _
"dbo.tb_Productos ON dbo.tb_PedidosCliDetalle.ProductoId = dbo.tb_Productos.ProductoId INNER JOIN " & _
"dbo.tb_Cli ON dbo.tb_PedidosCli.CliId = dbo.tb_Cli.ClienteId " & _
"WHERE (dbo.tb_PedidosCli.PedidoId = " & intNumeroPedido & ")"
SQL2 = "SELECT dbo.tb_OF.Numero, dbo.tb_Productos.Nombre, dbo.tb_OF.CantidadPedida, dbo.tb_OF.CantidadFabricada, dbo.tb_OF.CantidadPendiente " & _
"FROM dbo.tb_Cli INNER JOIN " & _
"dbo.tb_OF ON dbo.tb_Cli.ClienteId = dbo.tb_OF.ClienteId INNER JOIN " & _
"dbo.tb_PedidosCli ON dbo.tb_OF.IdPedido = dbo.tb_PedidosCli.PedidoId AND dbo.tb_Cli.ClienteId = dbo.tb_PedidosCli.CliId INNER JOIN " & _
"dbo.tb_Productos ON dbo.tb_OF.ProductoId = dbo.tb_Productos.ProductoId " & _
"WHERE (dbo.tb_PedidosCli.PedidoId = " & intNumeroPedido & ")"
'Abrir el reporte
Screen.MousePointer = vbHourglass
mflgContinuar = True
Set crReport = crApp.OpenReport("c:\proyectos\PMP\Informes\PedidoCliente.rpt", 1)
Set crSubReport = crApp.OpenReport("c:\proyectos\PMP\Informes\OFPedidoCliente.rpt", 1)
' ********************* cargo el recordset
Set adoRS = ObtenerAdoRs(SQL)
Set adoRS2 = ObtenerAdoRs(SQL2)
crReport.Database.SetDataSource adoRS
crSubReport.Database.SetDataSource adoRS2
' *********************** cargo los parametros
Set crParamDefs = crReport.ParameterFields
For Each crParamDef In crParamDefs
Select Case crParamDef.ParameterFieldName
Case "pPedidoNum"
crParamDef.AddCurrentValue (prmPedidoNum)
Case "pCliente"
crParamDef.AddCurrentValue (prmCliente)
Case "pDireccion"
crParamDef.AddCurrentValue (prmDireccion)
Case "pCP"
crParamDef.AddCurrentValue (prmCP)
Case "pLocalidad"
crParamDef.AddCurrentValue (prmLocalidad)
Case "pProvincia"
crParamDef.AddCurrentValue (prmProvincia)
End Select
Next
' ejecuto el report
CRViewer.ReportSource = crReport
'CRViewer.ReportSource = crSubReport
CRViewer.ViewReport
Screen.MousePointer = vbDefault
Set crParamDefs = Nothing
Set crParamDef = Nothing
Exit Sub
ErrHandler:
If Err.Number = -2147206461 Then
MsgBox "El archivo de reporte no se encuentra, restáurelo de los discos de instalación", _
vbCritical + vbOKOnly
Else
MsgBox Err.Description, vbCritical + vbOKOnly
End If
mflgContinuar = False
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set crReport = Nothing
Set crSubReport = Nothing
Set crApp = Nothing
End Sub
ERROR:
Logon failed.
Details: ADO ERROR CODE: 0X80040E4D
Source: Microsoft OLEDB Provider for SQL SERVER
Description: Login failed for user 'sa'
SQL STATE: 42000
Native error: 18456
1 Respuesta
Respuesta de denciso
1