Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
This code returns null where sql stored procedure returns 3 rows.

I'm trying to to use below stored procedure
SQL
ALTER proc  PrintInventoryStockTBL2 
@Store_id int,
@InventoryDate date 
 
as
  select InventoryId,InventoryName,Product_id,Product_name,Store_id,Store_name,Quantity,
RealQuantity,Inability,Increase,InventoryDate from InventoryStockTBL 
  where Store_id=@Store_id  and InventoryDate=@InventoryDate


C#
try
            {
                Reports.Report2 reportcustomer = new Reports.Report2();
                reportcustomer.SetDatabaseLogon("pc1", "12", "Server", "MnStores", false);
                reportcustomer.SetParameterValue("@Store_id", this.txtStore_id.Text);
                reportcustomer.SetParameterValue("@InventoryDate", this.dateTimePicker1.Text);
 
                Reports.FormReport fmct = new Reports.FormReport();
                fmct.crystalReportViewer1.ReportSource = reportcustomer;
                fmct.ShowDialog();
            }
            catch { }
Posted
Updated 28-Apr-15 21:07pm
v2
Comments
Tomas Takac 29-Apr-15 3:21am    
1) Empty catch: check if you are not swallowing an exception. 2) Are you sure you are running the SP with the same parameters in both cases?
Member 11280947 29-Apr-15 3:33am    
what do you mean
Sinisa Hajnal 29-Apr-15 4:55am    
Set a breakpoint in the code and step through.

In catch block put a message box or something so you know if something breaks. Ensure that reportcustomer contains the data.
[no name] 29-Apr-15 5:15am    
Place a breakpoint at
fmct.crystalReportViewer1.ReportSource = reportcustomer;
Check reportCustomer is returning any values or not.
coded007 30-Apr-15 4:04am    
Can u please let us know the inventory date format and your date picker date format so that we can help you in better way

If you are not getting any error ,then the problem is with the date format.
change
reportcustomer.SetParameterValue("@InventoryDate", this.dateTimePicker1.Text);

to
reportcustomer.SetParameterValue("@InventoryDate", this.dateTimePicker1.Value);
 
Share this answer
 
v2
check the format of date I think date is not in correct format.
 
Share this answer
 

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