Skip to Content
author's profile photo Former Member
Former Member

Problems with report. Missing columns in reports


i have so much problem with this report. i have this code:

Button generates the report I have this code:

Public Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

Dim rpt As New reporte


Dim fechadesde As String

Dim idEmpresa As Integer

Dim fechahasta As String

If RadioButton1.Checked Then

idEmpresa = 1


idEmpresa = 2

End If

If txtdesde.Text = "" Then

fechadesde = Convert.ToString("2012/01/01")


fechadesde = txtdesde.Text

End If

If txthasta.Text = "" Then

fechahasta = Convert.ToString("2099/01/01")


fechahasta = txthasta.Text

End If

' Obtenemos el objeto DataTable.


Dim dt As DataTable = Me.GetDataTable(idEmpresa, fechadesde, fechahasta)

DataGridView1.DataSource = dt

Dim ds As New DataSet


Dim formulario As New generar_reporte


formulario.CrystalReportViewer1.ReportSource = rpt

formulario.CrystalReportViewer1.Dock = DockStyle.Fill

Dim frmreport As New Form()

With frmreport


.Text = "Generar Reporte"

.WindowState = FormWindowState.Maximized


End With

Catch ex As Exception


End Try

Here the function to get the data:

Private Function GetDataTable(ByVal idEmpresa As Integer, ByVal fechadesde As String, ByVal fechahasta As String) As DataTable


Using cnn As New MySqlConnection("Server=localhost;Database=grupomontes;Uid=root;Pwd=;")

Dim cmd As MySqlCommand = cnn.CreateCommand()

cmd.CommandText = _

"SELECT a.Fecha AS fecha, a.Num_Albaran AS Num_Albaran," & _

"e.Razon_social_empresa AS Razon_Social_Empresa, c.Razon_Social AS Razon_Social, p.Nombre AS Nombre, a.neto AS Neto " & _

"FROM Productos AS p INNER JOIN (Empresas AS e " & _

"INNER JOIN (Clientes AS c INNER JOIN Albaranes AS a " & _

"ON c.Id_Clientes = a.Id_Cliente) ON e.Id_Empresa = a.Id_Empresa) " & _

"ON p.Id_Producto = a.Id_Producto " & _

"WHERE e.Id_Empresa=@idEmpresa and a.fecha >= @fechadesde and a.fecha <= @fechahasta;"

cmd.Parameters.AddWithValue("@idEmpresa", idEmpresa)

cmd.Parameters.AddWithValue("@fechadesde", fechadesde)

cmd.Parameters.AddWithValue("@fechahasta", fechahasta)

Dim da As New MySqlDataAdapter(cmd)

Dim dt As New DataTable("albaranes")


Return dt

End Using


' Devolvemos la excepción al procedimiento llamador


End Try

End Function

Just load the data that are not related to other tables. The other fields are empty in my report. The only fields not related to any other tables are now, and net id_albaran these that if I sample.

To razon_social company (related to the company table), razon_social (related to the Customers table), name (related to the Products table) I get these fields empty report.

What could be?


Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jun 05, 2012 at 02:11 PM

    As you are doing this:


    formulario.CrystalReportViewer1.ReportSource = rpt

    the rest of the database connection is of no consequence to Crystal Reports. E.g.; the database connection has been essentially converted / abstracted to an ADO .NET Dataset and this is all the report cares about. To troubleshoot the issue, see the blogTroubleshooting Issues with VS .NET Datasets and Crystal Reports.

    If that does not help, yo may want to provide more basic info:

    Exact version of CR used

    Version of .NET

    Database used

    Also since you are using datasets, see the following:

    1511438 - How to use datasets to pass data to crystal reports

    Crystal Reports for Visual Studio .NET - Walkthrough - Reporting Off ADO.NET Datasets

    And a bit of searching (search box, top right corner) will bring other resources...

    - Ludek

    Follow us on Twitter

    Got Enhancement ideas? Try the SAP Idea Place

    Share Your Knowledge in SCN Topic Spaces

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.