I have a query
that when executing it loads the data perfectly according to a id
, now, I need to generate a report that brings me that query
(filtered with id
).
After a lot of struggle with the odbc
, I can access the connection from the designer of crystal report
, but until I get there, I only see the tables, it does not let me work with a stored procedure so I discard it, I have to do it in pure consultation, my question is:
How do I pass the parameter to the report?
I have the following:
1.- The parameter created in the crystalreport
(it works for me, since it asks for the parameter when I execute the project and it filters well).
2.- A form
in which I have a text box, that's where I should enter the code and call the execution of crystalreport
.
I know that when I press the button to generate the form, it should pass to the crystal the value of the code that is in the textbox, but I do not know how to do this.
This is the method I have created:
Public Sub generarInformeIncidencia()
conexionMYSQL = New MySqlConnection
conexionMYSQL.ConnectionString = ("server=localhost;User Id=soporte;database=db_incidencias_muniquel;password=123")
Dim da As New MySqlDataAdapter
Dim dt As New DataTable
Dim fuente As New BindingSource
Dim frm As New frmPrincipal
'frm.txtIDRegSoporte.Text = lblIdRegistro.Text
'Usamos un Capturador de Errores
Try
'Me.dgIncidenciasAsignadas.Refresh()
conexionMYSQL.Open()
'Dim queryDefinitiva As String = ("SELECT inc.id_incidencia, inc.id_registro_soporte, est.identificacion_estado, met.identificacion_metodo, inc.fecha_registro,niv.id_nivel,niv.identificacion_nivel, cat.identificacion_categoria, scat.identificacion_subcategoria, inc.detalle_incidencia from tbl_incidencias inc INNER JOIN tbl_estados_incidencia est ON inc.id_estado=est.id_estado INNER JOIN tbl_metodos_ingreso_incidencia met ON inc.id_metodo_ingreso=met.id_metodo_ingreso INNER JOIN tbl_niveles_incidencia niv ON inc.id_nivel=niv.id_nivel INNER JOIN tbl_categoria_incidencia cat ON inc.id_categoria=cat.id_categoria INNER JOIN tbl_subcategoria_incidencia scat ON inc.id_subcategoria=scat.id_subcategoria WHERE id_registro_soporte=@id_registro_soporte")
Dim queryDefinitiva As String = ("SELECT inc.id_incidencia, tipo.identificacion_solicitud, inc.fecha_registro, niv.identificacion_nivel, est.identificacion_estado, met.identificacion_metodo, fun.nombre_funcionario, cat.identificacion_categoria, scat.identificacion_subcategoria, inc.detalle_incidencia, sop.nombre_funcionario FROM tbl_incidencias inc LEFT JOIN tbl_metodos_ingreso_incidencia met ON inc.id_metodo_ingreso=met.id_metodo_ingreso LEFT JOIN tbl_funcionario fun ON inc.id_registro=fun.id_registro LEFT JOIN tbl_funcionario_soporte sop ON inc.id_registro_soporte=sop.id_registro_soporte LEFT JOIN tbl_tipo_solicitud tipo ON inc.id_tipo_solicitud=tipo.id_tipo_solicitud LEFT JOIN tbl_categoria_incidencia cat ON inc.id_categoria=cat.id_categoria LEFT JOIN tbl_subcategoria_incidencia scat ON inc.id_subcategoria=scat.id_subcategoria LEFT JOIN tbl_niveles_incidencia niv ON inc.id_nivel=niv.id_nivel LEFT JOIN tbl_estados_incidencia est ON inc.id_estado=est.id_estado WHERE inc.id_incidencia=@idIncidencia")
comando = New MySqlCommand(queryDefinitiva, conexionMYSQL)
'comando.Parameters.AddWithValue("@id_registro_soporte", Convert.ToInt32(lblIdRegistro.Text))
da.SelectCommand = comando
da.Fill(dt)
InformeFinalIncidencia1.SetParameterValue("idIncidencia", txtId.Text)
visorIncidencia.ReportSource = InformeFinalIncidencia1
visorIncidencia.Show()
conexionMYSQL.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
conexionMYSQL.Dispose()
End Try
End Sub
Attentive to your comments.