468,110 Members | 1,949 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

VS2008 report using values from a parametized Stored procedure

2
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")
  3.  
Secondly i select empno from datagrid view as the parameter value which I pass to the SP

Expand|Select|Wrap|Line Numbers
  1.  
  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()
  5.  
  6.         dbcall.CallparametizedSP("payrollarchivedataview", "@e", empno)
  7.  
  8.  
The sub that makes a db call

Expand|Select|Wrap|Line Numbers
  1.  
  2.     Public Sub CallparametizedSP(ByVal procedureName As String, ByVal parameter As String, ByVal value As String)
  3.  
  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()
  13.  
  14.  
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 8522
Frinavale
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 )

-Frinny
Jan 8 '15 #2
szoora
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
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.