Exemplo n.º 1
0
    // This function gets the user activity from the tblPersonnel
    public static clsPersonnel GetPersonnel(string Database, string strSearch)
    {
        //  New instances of dsUserActivity, OleDbConnection and OleDbAdapter
        clsPersonnel     DS;
        OleDbConnection  sqlConn;
        OleDbDataAdapter sqlDA;

        // Connection string using OleDbConnection
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Database);
        // Select statement, retrieves all data from tblPersonnel
        if (strSearch == null || strSearch.Trim() == "")
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);
        }
        else
        {
            sqlDA = new OleDbDataAdapter("select * from tblPersonnel where LastName = '" + strSearch + "'", sqlConn);
        }
        // new dsUserAvtivity instantiated
        DS = new clsPersonnel();
        // tblUserActivity data assigned
        sqlDA.Fill(DS.tblPersonnel);
        // data is returned
        return(DS);
    }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         //Declare the Dataset
         clsPersonnel myDataSet = new clsPersonnel();
         // assign search value to string variable
         string strSearch = Request["txtSearch"];
         //Fill the dataset with shat is returned from the method.
         myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.accdb"), strSearch);
         //Set the DataGrid to the DataSource based on the table
         grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];
         //Bind the DataGrid
         grdViewPersonnel.DataBind();
     }
 }