Resources:
protected void btnAdd_Click(object sender, EventArgs e)
{
string adminNumber = txtAdminNumber.Text.ToString();
string surname = txtSurname.Text.ToString();
string forname = txtForname.Text.ToString();
//Boolean induction = true;
Boolean induction = Convert.ToBoolean(ddlInduction.SelectedItem.Value.ToString());
string called = "called";
string conString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\inetpub\wwwroot\GYMREG\App_Data\GymReg.accdb";
OleDbConnection conn = new OleDbConnection(conString);
string sql = "Insert into dbo_vwStudCYAll(AdmissionNumber, Surname, Forename, Called, Induction) values(?,?,?,?,?)";
OleDbCommand comm = new OleDbCommand(sql, conn);
comm.CommandType = CommandType.Text;
comm.Parameters.AddWithValue("AdmisssionNumber", adminNumber);
comm.Parameters.AddWithValue("Surname", surname);
comm.Parameters.AddWithValue("Forename", forname);
comm.Parameters.AddWithValue("Called", called);
comm.Parameters.AddWithValue("Induction", induction);
conn.Open();
try
{
comm.ExecuteNonQuery();
}
catch(Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
}
No comments:
Post a Comment