This my code where my passing dates and I want to display the data from the table as its from sql to view in ASP.NET MVC 5. And that two dates are also comes from view means after selecting this dates I have to pass it into the parameter in stored procedure
public DataTable Get_Availability(string ID = "")
{
string aDate = "03/03/2017";
string dDate = "20/03/2017";
DateTime oDate = Convert.ToDateTime(aDate);
DateTime uDate = Convert.ToDateTime(dDate);
queryString = "FO.USP_Check_AvailabilityOFRoom";
try
{
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand(queryString, conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(New SqlParameter("@Date_Of_Birth",Data.SqlDbType.DateTime));
cmd.Parameters("@Date_Of_Birth").Value = DOB
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
return ds.Tables[0];
}
}
}
}
catch
{
return null;
}
return null;
}