title: Cannot add data to table in MS Access 2013 from Visual Studio 2012
body: <p>I made a web form in Visual Studio 2012 and am making a User Management form so a manager can login and go to this page and edit, delete, or add users.  I'm using MS Access 2013 and I'm used to working in VS 2008. This exact same code works in VS 2008 with Access 2013. On the form I have a Gridview which is bound to the table in Access. For some reason the <code>if()</code> statement in the button <code>Click</code> event that calls the function in my data layer class keeps returning <code>false</code> so my result label keeps saying the user has not been added to the database.  </p>
  
  <p>I've tried passing the values as just <code>txtUser.Text</code> and how it's written now as <code>ToString()</code>.</p>
  
  <p>Here's the button click code:</p>
  
  <pre><code>protected void btnAddUser_Click(object sender, EventArgs e)
  {
  
  
      //makes call to saveusers class to add the new user to the database sending the values with it
      if (clsDataLayer.SaveUsers(Server.MapPath("~/App_Data/TPSDB.accdb"),
                                   txtUser.Text.ToString(),
     txtPassword.Text.ToString()))
          {
              //if saveusers function is successful and true then informs the user of the results
  
                  grdEditManagers.DataBind();
                  lblResults.Text = "The user has been added to the database!";
  
          }
          //if saveusers function is not successful or false then informs user
          else
          {
              lblResults.Text = "The user has not been added to the database!";
  
          }
  }
  </code></pre>
  
  <p>Here's the <code>SaveUsers()</code> code in the <code>clsDataLayer</code> class:</p>
  
  <pre><code>//this function saves the new user
  public static bool SaveUsers(string Database, string UserName, string UserPassword)
  {
  
      bool recordSaved;
      // Creates transaction for rollback in case of error
      OleDbTransaction myTransaction = null;
      try
      {
          // creates variable of a new connection to DB
          OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" +
                                                     "Data Source=" + Database);
          conn.Open();//opens connection
          OleDbCommand command = conn.CreateCommand();
          string strSQL;
  
          // beginning of the commit or rollback transaction
          myTransaction = conn.BeginTransaction();
          command.Transaction = myTransaction;
  
          //strSQL assigned to first and last names only
          strSQL = "Insert into tblManagerLogin " +
                   "(UserName, Password) values ('" +
                   UserName + "', '" + UserPassword + "')";
          // SQL command for stored procedure
          command.CommandType = CommandType.Text;
          command.CommandText = strSQL;
  
  
          // statement against connection returns number of rows affected
          command.ExecuteNonQuery();
  
  
          // ends the rollback or commit block
          myTransaction.Commit();
  
          // close database connection
          conn.Close();
          recordSaved = true;
      }
      catch (Exception ex)
      {
          // rolls back both entries in case an error is caught
          myTransaction.Rollback();
          recordSaved = false;
  
      }
  
      return recordSaved;
  }
  </code></pre>