Question

Locked

nullable datatypes in .net

By dipak.thesiya ·
Hi all i am using Coalesce function in sqlserver 2005 following is sp
ALTER PROCEDURE [dbo].[GetAllBillDetails]
(
@FromDate AS DATETIME,
@ToDate AS DATETIME
)
AS
BEGIN
DECLARE @Err int

SELECT
BillNo,
SalesDate,
CustName,
Address,
Discount,
TotalAmount,
NetPayable
FROM
Sales
WHERE
SalesDate BETWEEN COALESCE(@FromDate,SalesDate)
AND COALESCE(@ToDate,SalesDate)
SET @Err = @@Error
RETURN @Err
END

following is code to in C# to call this sp


private void BindGrid()
{
SqlCommand command = new SqlCommand("GetAllBillDetails", sqlConn);
SqlDataAdapter ada = new SqlDataAdapter();
DataSet dataSet = new DataSet("Master");
ada.TableMappings.Add("Table", "Master");
command.CommandType = CommandType.StoredProcedure;
DateTime? fdate;
DateTime? todate;

fdate = dtpFromDate.Value.Date;
todate = dtpToDate.Value.Date;

if (!dtpFromDate.Checked)
{
fdate = null;
}

if (!dtpToDate.Checked)
{
todate = null;
}

command.Parameters.Add(new SqlParameter("@FromDate", fdate));
command.Parameters.Add(new SqlParameter("@ToDate", todate));
ada.SelectCommand = command;
ada.Fill(dataSet);
}

It is giving me error like procedure or function GetAllBillDetails requires parameter @FromDate which was not supplied.

Can any one help me to solve this issue...
Dipak Thesiya
DRC Pvt Ltd...

This conversation is currently closed to new comments.

0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Software Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums