try
{
// Retrieve the connection string from the settings file.
string conString = Properties.Settings.Default.Database1ConnectionString;
// Open the connection using the connection string.
using (SqlCeConnection con = new SqlCeConnection(conString))
{
con.Open();
using (SqlCeCommand com = new SqlCeCommand("INSERT INTO Employee_Records VALUES(@First_Name, @Surname, @Telephone, @Address1, @Address2, @County, @Postcode, @Start_Date, @Mobile, @Email)", con))
{
com.Parameters.AddWithValue("@First_Name", textBox1.Text);
com.Parameters.AddWithValue("@Surname", textBox3.Text);
com.Parameters.AddWithValue("@Telephone", textBox8.Text);
com.Parameters.AddWithValue("@Address1", textBox4.Text);
com.Parameters.AddWithValue("@Address2", textBox5.Text);
com.Parameters.AddWithValue("@County", textBox6.Text);
com.Parameters.AddWithValue("@Postcode", textBox7.Text);
com.Parameters.AddWithValue("@Start_Date", textBox11.Text);
com.Parameters.AddWithValue("@Mobile", textBox9.Text);
com.Parameters.AddWithValue("@Email", textBox10.Text);
com.ExecuteNonQuery();
}
}
this.Close();
}
catch (Exception F)
{
MessageBox.Show (F.Message.ToString());
this.Close();
}
string conString = Properties.Settings.Default.Database1ConnectionString;
using (SqlCeConnection con = new SqlCeConnection(conString))
{
con.Open();
// Read in all values in the table.
using (SqlCeCommand com = new SqlCeCommand("SELECT First_Name FROM Employee_Records", con))
{
SqlCeDataReader reader = com.ExecuteReader();
while (reader.Read())
{
String num = reader.GetString(0);
MessageBox.Show(num);
}
}
}

New Topic/Question
Reply



MultiQuote





|