Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void addRecord()
- {
- string connectString =
- "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =mmodb.accdb";
- OleDbConnection myConnection = new OleDbConnection(connectString);
- //Add variables from fields here
- string insertSQL
- = "INSERT INTO PLAYER_TBL "
- + "(LASTNAME, FIRSTNAME, ALIAS, STREET, CITY, STATE, PHONE, EMAIL) "
- + "VALUES (@LastName, @FirstName, @Alias, @Street, @City, @State, @Phone, @Email)";
- OleDbCommand insertCmd = new OleDbCommand(insertSQL, myConnection);
- insertCmd.Parameters.AddWithValue("@LASTNAME", LastName);
- insertCmd.Parameters.AddWithValue("@FIRSTNAME", FirstName);
- insertCmd.Parameters.AddWithValue("@ALIAS", Alias);
- insertCmd.Parameters.AddWithValue("@STREET", Street);
- insertCmd.Parameters.AddWithValue("@CITY", City);
- insertCmd.Parameters.AddWithValue("@STATE", State);
- insertCmd.Parameters.AddWithValue("@PHONE", Phone);
- insertCmd.Parameters.AddWithValue("@EMAIL", Email);
- try
- {
- myConnection.Open();
- insertCmd.ExecuteNonQuery();
- myConnection.Close();
- }
- catch (Exception err)
- {
- myConnection.Close();
- MessageBox.Show(err.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement