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 SontakkePosted Mar 28, 2017, 6:27 AM
Jes SiePosted Mar 31, 2017, 1:46 AM
Nitin SontakkePosted Mar 28, 2017, 6:32 AM
Nitin SontakkePosted Mar 28, 2017, 6:30 AM