void GetDatabaseConnection1()
{
//this is going to be ran after logging in
//Creates a connection with the database
string DbfilePath = @"C:\Users\matth\source\repos\Project code iteration one\Project but forms\Project but forms\bin\Debug\ProjectDataBase.accdb";
connection = new OleDbConnection("Provider=Microsoft.ACE.OleDb.16.0;DataSource=" + DbfilePath);
dt = new DataTable();
adapter = new OleDbDataAdapter("SELECT *FROM MainCalculationTable",connection);
connection.Open();
adapter.Fill(dt);
connection.Close();
}
void Insert()
{
connection = new OleDbConnection("Provider=Microsoft.ACE.OleDb.16.0; Data Source = ProjectDataBase.accdb");
GetDatabaseConnection1();
string query = "INSERT INTO StudentTable (YearGroup,FormGroup,FirstName,LastName,ScienceType) VALUES" + "(@yearGroup,@formGroup,@firstName,@lastName,@scienceType)";
cmd = new OleDbCommand(query, connection);
cmd.Parameters.AddWithValue("@yearGroup",yearGroupInput.Text);
cmd.Parameters.AddWithValue("@formGroup",formGroupTextBox.Text);
cmd.Parameters.AddWithValue("@firstName",firstNameTextBox.Text);
cmd.Parameters.AddWithValue("@lastName",lastNameTextBox.Text);
cmd.Parameters.AddWithValue("@scienceType",scienceClassTextBox.Text);
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
}