//populates a dateset with information from the Vehicle Table public dsVehicle findVehicle(int vehicleID) { //creates an SQL query that returns vehicles with a specific vehicleID string sqlStmt = "select * from Vehicle where vehicleID like '" + vehicleID + "'"; OleDbDataAdapter sqlDataAdapter = new OleDbDataAdapter(sqlStmt, dbConnection); dsVehicle tempDataSet = new dsVehicle(); sqlDataAdapter.Fill(tempDataSet.Vehicle); //returns the resulting data set -- should be only up to 1 line return(tempDataSet); }
//populates a dropDownMenu with all Vehicles for sale from the Vehicles Table public dsVehicle dsVehicleDropDown() { //This SQL query creates a dataset with two columns //Column 1: Vehicle ID //Column 2: Vehicle ID: VIN //(Future TO DO): Remove all vehicles that have sold //(Future TO DO): Include new vehicle Year/Make/Model Information for the dropDownMenu string sqlStmt = "Select vehicleID, vehicleID & ': ' & vin AS Vehicle FROM Vehicle"; OleDbDataAdapter sqlDataAdapter = new OleDbDataAdapter(sqlStmt, dbConnection); dsVehicle tempDataSet = new dsVehicle(); sqlDataAdapter.Fill(tempDataSet.Vehicle); //returns as resulting data set -- should expect multiple rows return(tempDataSet); }
//populates the dropdown list with information from the Vehicle Table public void populateDropDownList(int sValue) { try { dsVehicle dsPopulate = new dsVehicle(); string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); dsPopulate = dataLayerObj.dsVehicleDropDown(); ddlVehicleID.DataSource = dsPopulate; ddlVehicleID.DataTextField = "Vehicle"; ddlVehicleID.DataValueField = "vehicleID"; ddlVehicleID.DataBind(); //re-selects the vehicle with the value of sValue one the dropdownmenu has been repopulated ddlVehicleID.SelectedValue = sValue.ToString(); } catch (Exception error) { Warnings.Text = "Critical Error: " + error; } }