Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=C:UsersstoneDesktopLastoneMaintMainMaintMainDatabase1.mdf;Integrated Security=True");
  2.  
  3.  
  4. SqlCommand cmd = new SqlCommand();
  5.  
  6. public Form1()
  7. {
  8. InitializeComponent();
  9. cmd.Connection = con;
  10. }
  11.  
  12. private void Button1_Click(object sender, EventArgs e)
  13. {
  14. cmd.CommandText = "inster into Records(Name) values ('" + txtID.Text + "' )";
  15. con.Open();
  16. cmd.ExecuteNonQuery();
  17. con.Close();
  18. MessageBox.Show("Data has beed record.");
  19. }`
  20.  
  21. System.Data.SqlClient.SqlException: 'Incorrect syntax near the keyword 'into'.'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement