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
GetCompulsoryCoverage( string vehicleType, string Option) - {
- List
getVehicleType = new List (); - 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;
- }


Nitin SontakkeRank #264 · 9.6K reputationPosted Mar 28, 2017, 2:27 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Mar 28, 2017, 2:30 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Mar 28, 2017, 2:32 AM EDT
Jes SieRank #1,285 · 1.3K reputationPosted Mar 30, 2017, 9:46 PM EDT