Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/03/2007, 14:47
neoscalybur
 
Fecha de Ingreso: marzo-2007
Mensajes: 3
Antigüedad: 17 años, 1 mes
Puntos: 0
Exclamación Ayuda con Crystal Reports y VB.NET 2005

Hola buen dia a todos

Espero y puedan ayudarme. Tengo una clase para poder mandar los parametros al crystal reports, mi unico problema es al cambiar de servidor, mando la conexion del servidor por codigo pero al cargar el reporte en el viewer me sale el siguiente error:

Failed to open a rowset.
Details: ADO Error Code: 0x
Source: Microsoft OLE DB Provider for SQL Server
Description: Procedure or Function 'RepCostosVentas' expects parameter '@alm', which was not supplied.
SQL State: 42000
Native Error:
Failed to open a rowset.
Error in File C:\DOCUME~1ADMINI~1\CONFIG~1\Temp\temp_0580ef76-4095-4092-a407-06a860af741c
{E20B7795-241D-4548-81B4-3358AECC9288}.rpt:
Failed to open a rowset.

Este error es mas comun, pero a veces me sale la ventana de login al servidor.
El codigo de la clase es el siguiente:

Imports CrystalDecisions.Shared
Imports CrystalDecisions.Windows
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.CrystalReports
Imports CrystalDecisions.CrystalReports.Engine
Imports Microsoft.VisualBasic
Imports Microsoft.Win32
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlConnection
Imports System.Data.OleDb

Public Class Reportes
Private lista As New ParameterFields
Private Const ID As String = "adolfo" 'ESTA ES LA CONSTANTE DE USUARIO
Private Const Psw As String = "siete" 'ESTA ES LA CONSTANTE DE PASSWORD
Private Reporte As ReportDocument
Private View As Object
Private RptServer, RptBase As String

''' <summary>
''' Asignar el Reporte
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property RepName() As ReportDocument 'ESTA PROPIEDAD SIRVE PARA ASIGNAR EL REPORTE
Get
Return Reporte
End Get
Set(ByVal value As ReportDocument)
Reporte = value
End Set
End Property

''' <summary>
''' Asignar el visor
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Viewer() As Object 'ESTA PROPIEDAD SIRVE PARA ASIGNAR EL VISOR
Get
Return View
End Get
Set(ByVal value As Object)
View = value
End Set
End Property

''' <summary>
''' ESTE METODO SIRVE PARA FILTAR LOS DATOS EN EL PROCEDIMIENTO ALMACENADO
''' PASANDOLE LOS VALORES A LAS VARIABLES DEL PROCEDIMIENTO ALMACENADO
''' </summary>
''' <param name="valor">VALOR DE LA VARIABLE DEL PROCEDIMIENTO ALMACENADO</param>
''' <param name="nombre_parametro">NOMBRE DE LA VARIABLE DEL PROCEDIMIENTO ALMACENADO</param>
''' <remarks></remarks>
Private Sub ingresa_valores(ByVal valor As String, ByVal nombre_parametro As String)
Dim Valores As New ParameterDiscreteValue
Dim DatosSP As New ParameterField
Valores.Value = valor
DatosSP.Name = nombre_parametro
DatosSP.CurrentValues.Add(Valores)
lista.Add(DatosSP)
End Sub

''' <summary>
''' MANDA LOS VALORES AL PROCEDIMIENTO ALMACENADO
''' </summary>
''' <param name="Valores">Se deben de ingresar los valores en el siguiente orden:
''' Valor para asignar al parametro del procedimiento almacenado.
''' Nombre del parametro del Procedimiento almacenado.
''' </param>
''' <remarks></remarks>
Sub REPSP(ByVal ParamArray Valores() As String)
Dim a As Integer
Dim Connection As New ConnectionInfo
lista.Clear()
SBKey() 'ESTE PROCEDIMIENTO SIRVE PARA RECUPERAR LOS VALORES DE LA BASE DE DATOS Y EL SERVIDOR DEL 'REGISTRO DE WINDOWS
With Connection
.ServerName = "RptServer"
.DatabaseName = "RptBase"
.UserID = ID
.Password = Psw
End With
For a = LBound(Valores) To UBound(Valores) Step 2
ingresa_valores(Valores(a), Valores(a + 1))
Next
View.ReportSource = Nothing
View.ShowRefreshButton = False
View.DisplayGroupTree = False
View.ParameterFieldInfo = lista
View.ReportSource = Reporte
RepConnInfo(Connection, Reporte)
End Sub

Private Sub SBKey() 'SIRVE PARA RECUPERAR LOS VALORES DEL SERVIDOR Y LA BASE DE DATOS DEL REGISTRO DE 'WINDOWS
Dim llave As RegistryKey
llave = Registry.LocalMachine.OpenSubKey("Software\AutoSof tKey", False)
RptServer = llave.GetValue("RptServer") 'SERVIDOR
RptBase = llave.GetValue("RptBase") 'BASE DE DATOS
End Sub

'METODO QUE UTILIZO PARA PASAR LA INFORMACION DE LA CONEXION AL REPORTE
Private Sub RepConnInfo(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)
Dim myTables As Tables = myReportDocument.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
Dim myTableLogonInfo As New TableLogOnInfo
myTableLogonInfo.ConnectionInfo = myConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
End Sub
End Class


Todo esto funciona bien si lo uso en el servidor en el que cree el reporte pero al cambiar de servidor ya no funciona y me sale el error arriba comentado, que podria hacer, ya intente con varias formas pero no lo he podido solucionar

ahhh!!!! De esta forma paso los parametros a la clase para que ejecute el reporte

Dim reporte2 As New Reportes 'CREO UNA NUEVA INSTANCIA DE LA CLASE "Reportes"

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim reporte As New CrystalReport1 'ESTE ES EL REPORTE
reporte2.RepName = reporte 'LE PASO EL REPORTE A LA CLASE
reporte2.Viewer = Me.CrystalReportViewer1 'LE PASO EL VIEWER A LA CLASE
reporte2.REPSP("0", "@p1") 'LE PASO LOS PARAMETROS DE FILTRADO
End Sub

TODO ESTO LO UTILIZO CON UN STORED PROCEDURE Y LOS PARAMETROS QUE PASO SON DEL STORE PROCEDURE