By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,463 Members | 771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,463 IT Pros & Developers. It's quick & easy.

VS2008 report using values from a parametized Stored procedure

P: 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")
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
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 9,731
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

P: 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.