Hi all
I want to select data from a database and display it on a GridView. My problem is it doe not return anything when i use the WHERE clause but when i use SELECT * it works. I am new in ASP.NET, please help.
here is the code i used:
[
qlDataSource datasource = new SqlDataSource();
datasource.ConnectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ToString();
datasource.SelectCommandType = SqlDataSourceCommandType.Text;
datasource.SelectCommand = "SELECT FlightID, FlightNo, @DeparturePlace, @DestinationLoc, DepartTime, ArrivalTime, SinglePrice, ReturnPrice FROM Status WHERE DeparturePlace = @DeparturePlace AND DestinationLoc = @DestinationLoc";
datasource.SelectParameters.Add("DeparturePlace", DropDownList1.SelectedValue);
datasource.SelectParameters.Add("DestinationLoc", DropDownList2.SelectedValue);
qlDataSource datasource = new SqlDataSource();
datasource.ConnectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ToString();
datasource.SelectCommandType = SqlDataSourceCommandType.Text;
datasource.SelectCommand = "SELECT FlightID, FlightNo, @DeparturePlace, @DestinationLoc, DepartTime, ArrivalTime, SinglePrice, ReturnPrice FROM Status WHERE DeparturePlace = @DeparturePlace AND DestinationLoc = @DestinationLoc";
datasource.SelectParameters.Add("DeparturePlace", DropDownList1.SelectedValue);
datasource.SelectParameters.Add("DestinationLoc", DropDownList2.SelectedValue);]