Is it possible to pass 2 parameters in web application but only 1 parameter comes from sql server db? The other parameter comes from a pre set dropdownlist. If it's possible, how to do it? This is what I have in mind but not sure if it is correct.
- public static List<CompulsoryTable> GetCompulsoryCoverage(string vehicleType, string Option)
- {
- List<CompulsoryTable> getVehicleType = new List<CompulsoryTable>();
- using (SqlConnection con = DBConnection.GetDbCon())
- {
- SqlCommand cmd = new SqlCommand("select * from tblCompulsoryTable where VehicleType = @VehicleType", con);
- cmd.CommandType = CommandType.Text;
- cmd.Parameters.AddWithValue("@VehicleType", vehicleType);
- cmd.Parameters.AddWithValue("@CompulsoryOptions", Option);
- con.Open();
-
- SqlDataReader rdr = cmd.ExecuteReader();
- while (rdr.Read())
- {
- CompulsoryTable Vehicles = new CompulsoryTable();
- Vehicles.VehicleType = rdr["VehicleType"].ToString();
- getVehicleType.Add(Vehicles);
- }
- }
- return getVehicleType;
- }