title: ALTER TABLE in Access database from C#
body: <p>I need to add <code>datagridview</code> data to a MS Access table, at the same time add a column into that table and update the column as well. please help me, I keep getting an error that says Syntax error in field definition and then says No value given for one or more required parameters.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
          string myConnectionString = " ";
  
          myConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/game/Desktop/3rd year/2nd Semester/INYM 328/EmployeeAttendanceRegister/EmployeeAttendanceRegister/EmployeeAttendanceRegister.accdb";
          OleDbConnection myConnection = new OleDbConnection(myConnectionString);
  
          string col1 = dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
          string col2 = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
          string col3 = dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString();
          string col4 = dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value.ToString();
          string col5 = dataGridView1[4, dataGridView1.CurrentCell.RowIndex].Value.ToString();
          string col6 = dataGridView1[5, dataGridView1.CurrentCell.RowIndex].Value.ToString();
          string col7 = dataGridView1[6, dataGridView1.CurrentCell.RowIndex].Value.ToString();
          string myInsertQuery = "INSERT INTO Attendance VALUES('" + col1 + "','" + col2 + "','" + col3 + "','" + col4 + "','" + col5 + "','" + col6 + "','" + col7 + "')";
  
          OleDbCommand myCommand = new OleDbCommand(myInsertQuery);
          myCommand.Connection = myConnection;
  
          myConnection.Open();
          try
          {
              myCommand.ExecuteNonQuery();
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message.ToString());
          }
          myConnection.Close();
          {
              string myConn = " ";
  
              myConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/game/Desktop/3rd year/2nd Semester/INYM 328/EmployeeAttendanceRegister/EmployeeAttendanceRegister/EmployeeAttendanceRegister.accdb";
              OleDbConnection myCon = new OleDbConnection(myConn);
  
              string myInsert = "ALTER TABLE Attendance ADD COLUMN SignIn";
              OleDbCommand myCom = new OleDbCommand(myInsert);
              myCom.Connection = myCon;
  
              myCon.Open();
              try
              {
                  myCom.ExecuteNonQuery();
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message.ToString());
              }
              myCon.Close();
          }
          {
              string myString = " ";
  
              myString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/game/Desktop/3rd year/2nd Semester/INYM 328/EmployeeAttendanceRegister/EmployeeAttendanceRegister/EmployeeAttendanceRegister.accdb";
              OleDbConnection myConnect = new OleDbConnection(myString);
              string Insert = "UPDATE Attendance SET SignIn = '" + dateTimePicker1.Value + "'";
  
              OleDbCommand myComm = new OleDbCommand(Insert);
              myComm.Connection = myConnect;
  
              myConnect.Open();
              try
              {
                  myComm.ExecuteNonQuery();
  
                  MessageBox.Show("Successfully Signed IN");
                  frmhomepage previousForm = new frmhomepage();
                  previousForm.Show();
                  this.Hide();
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message.ToString());
              }
  
              myConnect.Close();
          }
      }
  </code></pre>