Expand|Select|Wrap|Line Numbers
- string pName = textBox6.Text.Trim();
- string pMobile1 = textBox5.Text.Trim();
- string pHome = textBox3.Text.Trim();
- string pBusiness = textBox2.Text.Trim();
- string pEmail = textBox1.Text.Trim();
- string pCategory = comboBox1.SelectedText.Trim();
- Debug.Write("test0 ");
- SqlConnection conn = new SqlConnection(
- "Server = CLB125_25; Data Source = \\C:Documents and Settings\\SLU Student\\Desktop\\SmartDeviceProject1\\database1.sdf");
- Debug.Write("test1 ");
- SqlDataReader rdr = null;
- Debug.Write("test2 ");
- try
- {
- conn.Open();
- Debug.Write("test3");
- string actionString = "INSERT INTO Contacts(Name, Home_Phone, E-Mail, Address, Mobile, Category) VALUES(" + pName.ToString() + "," + pHome.ToString() + "," + pEmail.ToString() + "," + pBusiness.ToString() + "," + pMobile1.ToString() + "," + pCategory.ToString() + ")";
- SqlCommand cmd = new SqlCommand(actionString, conn);
- cmd.ExecuteNonQuery();
- rdr = cmd.ExecuteReader();
- while (rdr.Read())
- {
- Console.WriteLine(rdr[0]);
- }
- }
- catch (SqlException d)
- {
- Console.Write(d);
- }
- finally
- {
- if (rdr != null)
- {
- rdr.Close();
- }
- if (conn != null)
- {
- conn.Close();
- }
- }