Visual Basic - Crystal 10 desde VB 6.0 con stored procedure

Life is soft - evento anual de software empresarial
 
Vista:

Crystal 10 desde VB 6.0 con stored procedure

Publicado por Camila (1 intervención) el 11/03/2009 01:08:38
Por favor, necesito que alguien me ayude !!!!
Tengo que llamar desde VB 6.0 a un reporte de Crystal 10.5 que esta diseñado referenciando a un stored procedure y un parametro del mismo.
Si alguien sabe como invocarlo desde VB 6.0 pasandole solo una conexion al servidor SQl
se lo agradecería mucho.
Todos los ejemplos que encontré son pasandole un recordset, pero no encontré ninguno que lo haga de esta manera.
Es mucho mas performante dejar que el crystal reports invoque al Stored Procedure directamente.
Les comento que eso lo conseguí hacer en .NET y la diferencia es increible.

Gracias a todos por su ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Crystal 10 desde VB 6.0 con stored procedure

Publicado por Victor Sanchez (16 intervenciones) el 09/04/2009 01:15:33
Solo envia los parametros al Crystal , agregas el componente crViewer y listo...

Ej.

Option Explicit

Private crApp As New craxdrt.Application
Private crReport As New craxdrt.Report

Private mflgContinuar As Boolean
Private mstrParametro1 As String
Private mlngParametro2 As Long

Dim objSections As craxdrt.Sections
Dim objSection As craxdrt.Section
Dim objReportObjs As craxdrt.ReportObjects
Dim objReportObj As Object
Dim objSubReport As craxdrt.SubreportObject
Dim objReportInner As craxdrt.Report
Dim objDatabaseTable As craxdrt.DatabaseTable

Private Sub Form_Resize()

crViewer.Top = 0
crViewer.Left = 0
crViewer.Height = ScaleHeight
crViewer.Width = ScaleWidth

End Sub

Public Sub PasarParametros(lParam2 As Long)

mlngParametro2 = lParam2

End Sub

Private Sub Form_Load()

Dim crParamDefs As craxdrt.ParameterFieldDefinitions
Dim crParamDef As craxdrt.ParameterFieldDefinition
'Defina las varibles a nivel de modulo del formulario
Dim Tbl As craxdrt.DatabaseTable

On Error GoTo ErrHandler

Aplicar_skin Me

'Abrir el reporte

Screen.MousePointer = vbHourglass

mflgContinuar = True
'ruta del reporte
Set crReport = crApp.OpenReport(App.Path & "Reportes ureporte.rpt", 1)

' Parametros del reporte
Set crParamDefs = crReport.ParameterFields

For Each crParamDef In crParamDefs

Select Case crParamDef.ParameterFieldName
Case "@parametro"
crParamDef.ClearCurrentValueAndRange
crParamDef.AddCurrentValue mlngParametro2
End Select

Next

'Para los reportes de origen de datos ADODB, de tablas SQL SERVER
For Each Tbl In crReport.Database.Tables 'por cada tabla que incluiya en el Reporte
Tbl.ConnectionProperties("Provider") = "SQLOLEDB"
Tbl.ConnectionProperties("Data Source") = Servidor
Tbl.ConnectionProperties("Initial Catalog") = BaseDatos
Tbl.ConnectionProperties("User ID") = "sa"
Tbl.ConnectionProperties("Password") = ".007vj."
Next Tbl

crViewer.ReportSource = crReport
crViewer.DisplayGroupTree = False
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", vbCritical + vbOKOnly
Else
MsgBox Err.Description, vbCritical + vbOKOnly
End If

mflgContinuar = False
Screen.MousePointer = vbDefault



End Sub

Private Sub Form_Activate()

If Not mflgContinuar Then Unload Me



End Sub

Private Sub Form_Unload(Cancel As Integer)

Set crReport = Nothing

Set crApp = Nothing

End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar