using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Data.DataTable;
public class ServicesBLL
{
public DataTable SearchBuses(string fromcity, string tocity, string jdate, string bustype)
{
return ServicesDAL.SearchBuses(fromcity, tocity, jdate, bustype);
}
}
and here is the ServiceDAL code :
public static DataTable SearchBuses(string fromcity, string tocity, string jdate, string bustype)
{
SqlConnection con = new SqlConnection(Database.ConnectionString);
try
{
con.Open();
SqlDataAdapter sda = new SqlDataAdapter("searchbuses", con);
sda.SelectCommand.Parameters.AddWithValue("@fromcity", fromcity);
sda.SelectCommand.Parameters.AddWithValue("@tocity", tocity);
sda.SelectCommand.Parameters.AddWithValue("@jdate", jdate);
sda.SelectCommand.Parameters.AddWithValue("@bustype", bustype);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
sda.Fill(ds, "buses");
return ds.Tables[0];
}
catch (Exception ex)
{
HttpContext.Current.Trace.Write(
"Error in SearchBuses -->" + ex.Message);
return null;
}
finally
{
con.Close();
}
}