Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public static void Main(string[] args)
  2. {
  3.  
  4.  
  5. string cadenaConexion = "Data Source = localhost;Initial Catalog = CLIENTE ; Integrated Security = true;";
  6.  
  7. try
  8. {
  9. using (SqlConnection cn = new SqlConnection(datosConexion))
  10. {
  11. //Paso 2 - Abrir la conexión
  12. con.Open();
  13.  
  14.  
  15.  
  16. string SENTENCIA = "INSERT INTO TABLA (ID, NOMBRE)VALUES (1,'ENRIQUE');";
  17.  
  18. SqlCommand cmd = new SqlCommand(SENTENCIA, cn);
  19. try
  20. {
  21. cmd.ExecuteNonQuery();
  22. }
  23. catch (SqlException e)
  24. {
  25. Console.WriteLine(e.Message);
  26. }
  27. }
  28. }
  29. catch (Exception e)
  30. {
  31. Console.WriteLine(e.Message);
  32. }
  33. Console.ReadKey();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement