Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to generate a report showing payslips for a single employee using values from a SP with parameter values that have been passed from a datagrid row. However the report that is generated is blank. What am I missing. Below is what I have.

First I populate the datagrid view using values returned by a function called "sqlselect"

VB
Dim dbcall As New dbcalls
        dtgPayslip_Old.DataSource = dbcall.sqlselect("empno AS Employee_Number,empname AS Employee_Name, date AS Date", "payrollarchiveview")




Secondly i select empno from datagrid view as the parameter value which I pass to the SP

VB
Private Sub dtgPayslip_Old_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dtgPayslip_Old.CellDoubleClick
        Dim dbcall As New dbcalls
        Dim empno As String = dtgPayslip_Old.Item(0, dtgPayslip_Old.CurrentRow.Index).Value.ToString()

        dbcall.CallparametizedSP("payrollarchivedataview", "@e", empno)


<
The sub that makes a db call

VB
Public Sub CallparametizedSP(ByVal procedureName As String, ByVal parameter As String, ByVal value As String)

        conn.Open()
        cmd.Parameters.AddWithValue(parameter, value)
        cmd.Connection = conn
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = procedureName
        cmd.CommandTimeout = 6000
        cmd.ExecuteScalar()
        cmd.Dispose()
        conn.Close()



After all this I would expect details of the employee into the report But all I get are the column headings. How can I resolve this. Thank you community
Posted

1 solution

MSDN:
[ExecuteScalar] Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.

You probably have to use ExecuteReader to get the data and than fill a data source for the report...However you should check that your SP actually returns data!
 
Share this answer
 
Comments
Member 10376125 7-Jan-15 3:25am    
Still no data is returned to the report when I change to ExecuteReader. I have created a table where i can insert the returned data and I can already see the table being populated with the values. I could have the report getting the data from this new table BUT my client does not want me to change the database objects as I will have a couple of such reports to run, yet I do not want to create a table for every report.
Kornfeld Eliyahu Peter 7-Jan-15 3:29am    
What are you saying, that the returns and can be shown in a table, but not in the report?
How do you create/bind the report? Maybe the problem not with the data anymore?
Member 10376125 7-Jan-15 4:01am    
I created the report using a wizard and selected the SP as my datasource. I created a form where i add a report viewer control. True the returns are in the table but not on the report. I also tried a SP without parameters like SELECT empno, empname, payment, deduction FROM payroll. When I run the SP, data is returned but When I bind it to the report, No data is returned to the report. NOW the Question is......Does VS2008 report return data from a stored procedure?
Member 10376125 7-Jan-15 3:46am    
I created the report using a wizard and selected the SP as my datasource. I created a form where i add a report viewer control. True the returns are in the table but not on the report. I also tried a SP without parameters like SELECT empno, empname, payment, deduction FROM payroll. When I run the SP, data is returned but When I bind it to the report, No data is returned to the report. NOW the Question is......Does VS2008 report return data from a stored procedure?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900