470,613 Members | 2,348 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

VS2008 report using values from a parametized Stored procedure

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"

Expand|Select|Wrap|Line Numbers
  1.     Dim dbcall As New dbcalls
  2.         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

Expand|Select|Wrap|Line Numbers
  2.     Private Sub dtgPayslip_Old_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dtgPayslip_Old.CellDoubleClick
  3.         Dim dbcall As New dbcalls
  4.         Dim empno As String = dtgPayslip_Old.Item(0, dtgPayslip_Old.CurrentRow.Index).Value.ToString()
  6.         dbcall.CallparametizedSP("payrollarchivedataview", "@e", empno)
The sub that makes a db call

Expand|Select|Wrap|Line Numbers
  2.     Public Sub CallparametizedSP(ByVal procedureName As String, ByVal parameter As String, ByVal value As String)
  4.         conn.Open()
  5.         cmd.Parameters.AddWithValue(parameter, value)
  6.         cmd.Connection = conn
  7.         cmd.CommandType = CommandType.StoredProcedure
  8.         cmd.CommandText = procedureName
  9.         cmd.CommandTimeout = 6000
  10.         cmd.ExecuteReader()
  11.         cmd.Dispose()
  12.         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
Jan 7 '15 #1
2 8556
9,735 Expert Mod 8TB
Calling the ExecuteReader method alone does not actually retrieve the data. You have to read the data from the reader in order to load the data.

Please see the MSDN documentation for SqlCommand.ExecuteReader Method for more information about this method and how to use it (if you aren't connecting to a MS SQL Server database you will need to check out the documentation for the OleDbCommand.ExecuteReader Method )

Jan 8 '15 #2
The other method was not to run the db call the sp at all. I passed the parameter value directly to the form that has the report viewer control, And I had my reports as expected. Thanks
Jan 8 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Golawala, Moiz M (GE Infrastructure) | last post: by
reply views Thread by sbest | last post: by
1 post views Thread by vncntj | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.