West1989 wrote:
try
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "exec GetBooksByCategory @ID";
cmd.Connection = Connection;
cmd.Parameters.Add(new SqlParameter("ID", categoriID));
return cmd.ExecuteNonQuery();
}
You are doing wrong here. You are trying to execute Stored procedure ?
Look at this
<br />public int LoadByCategories(int categoriID)<br /> {<br /> Connection.Open();<br /> try<br /> {<br /> SqlCommand cmd = new SqlCommand();<br /> cmd.CommandType = System.Data.CommandType.StoredProcedure;<br /> cmd.CommandText="GetBooksByCategory";<br /> cmd.Connection = Connection;<br /> cmd.Parameters.Add(new SqlParameter("@ID", categoriID));<br /> return cmd.ExecuteNonQuery();<br /> }<br /> finally<br /> {<br /> Connection.Close();<br /> }<br /> }
Hope this will help you :)