Ayuda con Crystal y vb.net Mega URGENTE !!
Aqui tienes un ejemplo de como actualizar las tablas de tus informes con los datos de la Base de Datos que utilizarás.
Espero te ayude...
'Creas la variable de conexion en un modulo
''''''Public ConexionDatos As New SMTEC.ConaifSedigas.Calidad.Reporting.ConexionDatos
Public Informe As ReportClass
'Esto lo cargas al iniciar tu aplicación
Sub Load DataBaseInfo
ConexionDatos.Servidor=X
ConexionDatos .BaseDatos=x
ConexionDatos .Usuario=x
ConexionDatos .Password =X
End Sub
' Esto lo llamas desde tu botón Imprimir
Sub Print
Informe=RptTuInforme
Informe.Load()
Me.ReportViewer.ReportSource =Report.UpdateTablasInforme(Informe,ConexionDatos)
End Sub
'Interfaz para datos de conexion
Public Interface IDataConection
Property Servidor() As String
Property BaseDatos() As String
Property Usuario() As String
Property Password() As String
End Interface
'clase de conexion
Public Class ConexionDatos
Implements IDataConection
Sub New()
End Sub
Private _servidor As String
Private _basedatos As String
Private _usuario As String
Private _password As String
Public Property BaseDatos() As String Implements IDataConection.BaseDatos
Get
Return _basedatos
End Get
Set(ByVal value As String)
_basedatos = value
End Set
End Property
Public Property Password() As String Implements IDataConection.Password
Get
Return _password
End Get
Set(ByVal value As String)
_password = value
End Set
End Property
Public Property Servidor() As String Implements IDataConection.Servidor
Get
Return _servidor
End Get
Set(ByVal value As String)
_servidor = value
End Set
End Property
Public Property Usuario() As String Implements IDataConection.Usuario
Get
Return _usuario
End Get
Set(ByVal value As String)
_usuario = value
End Set
End Property
End Class
'Aqui tienes la clase para actualizar las tablas de tus informes y subinformes.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public NotInheritable Class Report
Private CrTables As Tables
Private CrTable As Table
Private crConnectionInfo As New ConnectionInfo
Public Shared Sub UpdateTablasInforme(ByVal reporte As CrystalDecisions.CrystalReports.Engine.ReportClass, MyConexionDatos as ConexionDatos)
crConnectionInfo.ServerName = MyConexionDatos.Servidor 'my.settings.Servidor
crConnectionInfo.UserID = MyConexionDatos.Usuario 'My.Settings.Usuario
crConnectionInfo.Password = MyConexionDatos.Password ' My.Settings.Password
crConnectionInfo.DatabaseName = MyConexionDatos.BaseDatos 'My.Settings.BaseDatos
UpdateTablas(reporte.Database.Tables,crConnectionInfo)
For Each subreporte As ReportDocument In reporte.Subreports
UpdateTablas(subreporte.Database.Tables,crConnectionInfo)
Next
End Sub
Private shared Sub UpdateTablas(CrTables as Tables,conexion as connectionInfo)
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = conexion
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
End Sub
End Class