So I'm trying to create a search using three tier and there aren't many good examples online so i tried it out to see if I can make it work but it just won't work for some reason. Can you please look at my code and see what I'm doing wrong?
Stored Procedure:
CREATE PROCEDURE [dbo].[GuestSearch]
@FirstName varchar(20),
@LastName varchar(20),
@Phone varchar(15)
AS
SELECT FirstName, Lastname, Phone
FROM Guest
WHERE FirstName LIKE '%'+@FirstName+'%'
AND LastName LIKE '%'+@LastName+'%' AND
Phone LIKE '%'+@Phone+'%'
BEL
public class GuestBEL
{
public int GuestID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Phone { get; set; }
}
BLL
public DataSet FindGuest()
{
GuestDAL objDAL = new GuestDAL();
return objDAL.FindGuest();
}
DAL
public DataSet FindGuest()
{
DataSet dts = new DataSet();
SqlCommand cmd = new SqlCommand("GuestSearch", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adapt = new SqlDataAdapter(cmd);
con.Open();
adapt.Fill(dts);
cmd.Dispose();
dts.Dispose();
con.Close();
return dts;
}
UI
protected void btnSearch_Click(object sender, EventArgs e)
{
DataSet data = new DataSet();
data = objBLL.FindGuest();
gvGuest.DataSource = data;
gvGuest.DataBind();
readGrid();
}
So When I type something in the search the gridview should display what i put in the text box but for some reason, the error i get is that 'Procedure or function 'GuestSearch' expects parameter '@FirstName', which was not supplied.'