help with sql query for report

0

I have to prepare a report in crystal report, showing the key, client, client name, credit amount and loan date fields. at the moment of executing what I already have, it throws me an error in the "fill of data" I assume that the query is wrong, I hope you can help me since I am not much of programming or things like that

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim con As SqlConnection = New SqlConnection("server=DESKTOP-SAHPQ10;Database=SistemadeVentas;UID=sa;Pwd=avilalopez12;")
        Dim comando As SqlCommand = New SqlCommand("Select Clientes.id_cliente,nombrecliente,apellido_paterno,apellido_materno,fecha_credito,monto,pagado from Clientes", con)
        Dim adaptador As SqlDataAdapter = New SqlDataAdapter
        con.Open()
        datos.Clear()
        adaptador.SelectCommand = comando
        adaptador.Fill(datos, "creditos")
        Dim rpt As New CrystalReport1
        rpt.Load()
        rpt.SetDataSource(datos)
        rpt.Refresh()
        CrystalReportViewer1.ReportSource = rpt
        rpt.Refresh()
    
asked by Jorge Avila Lopez 15.08.2018 в 01:47
source

1 answer

0

Fix your Query SQL:

Dim comando As SqlCommand = New SqlCommand("SELECT X.id_cliente, X.apellido_paterno, X.apellido_materno, X.fecha_credito, X.monto, X.pagado FROM Clientes X", con);

Recommendation: When you ask a question, I suggest that you do not expose the credentials of your connection, this must be private:

Dim con As SqlConnection = New SqlConnection("server=*****Database=********;UID=**;Pwd=*********;")
    
answered by 15.08.2018 в 17:08