I am trying to pull data from my table based on the button a user clicks, so if they click the 1940's button it will pull all products from that decade but I cant get the query to work. It has to do with the @decade parameter because that is where I am getting the user input from but it doesnt like it when I am trying to choose a column using that parameter
ImageButton decadeBtn = (ImageButton)sender;
var decade = decadeBtn.CommandArgument;
yearHead.InnerText = decade.ToString();
string cmd="";
DataSet ds;
if (typeOfArchive == "On Hand")
{
cmd = @"Select * From ARCHIVE_DECADE_TBL WHERE DECADE_@decade=@decade AND PRODUCT_LINE=@Line AND LOCATION is not null;";
}
else if(typeOfArchive == "All Other"){
cmd = @"Select * From ARCHIVE_DECADE_TBL WHERE DECADE_@decade=@decade AND PRODUCT_LINE=@Line AND LOCATION is null";
}
using (OleDbConnection dbConn = new OleDbConnection(connectionString))
using (OleDbDataAdapter dbCmdDecade = new OleDbDataAdapter(cmd, dbConn))
{
dbConn.Open();
dbCmdDecade.SelectCommand.Parameters.Add("@decade", OleDbType.Integer).Value = decade;
dbCmdDecade.SelectCommand.Parameters.Add("@line", OleDbType.VarChar).Value = productLine;
ds = new DataSet();
dbCmdDecade.Fill(ds, "products");
}