public static DataTable LoadGrid(string SelectedItem,string yearSelected)
{
DataTable tbl;
string a = SelectedItem;
string b = yearSelected;
string query =" SELECT top 10 SalesOrderID, RevisionNumber, OrderDate,DueDate,
"ShipDate, Status,OnlineOrderFlag,SalesOrderNumber,PurchaseOrderNumber,AccountNumber, CustomerID, SalesPersonID, st.Name AS TerritoryName,BillToAddressID, ShipToAddressID,ShipMethodID, CreditCardID, CreditCardApprovalCode,CurrencyRateID, SubTotal, TaxAmt, Freight,TotalDue,Comment, soh.rowguid, soh.ModifiedDate FROM Sales.SalesOrderHeader soh INNER JOIN Sales.SalesTerritory st ON soh.TerritoryID = st.TerritoryID"+
WHERE st.Name = "+a+"AND Datepart(year,OrderDate) = "+b;
tbl=DataAccess.cmd(query);
return (tbl);
}
the data passed to a
is a territory and to b is b
is year from 2 different dropdown list but the query is giving error saying invalid column name canada (suppose if i choose canada from the dropdown list) and canada is an item of a table in territory table in Name column