public DataTable searchCar(string search) { DataTable tb = new DataTable(); try { conn = MyConnection.getConnection(); con = new SqlConnection(conn); con.Open(); cmd = new SqlCommand("SearchCar", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Search", "%" + search + "%"); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(tb); } catch (Exception ex) { throw new Exception(ex.Message); } finally { closeConnection(); } return(tb); }
protected void Page_Load(object sender, EventArgs e) { MyConnection _connection; _connection = new MyConnection(); _cnObj = _connection.getConnection(); }