Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. public void Save()
  2. {
  3. string sql = "INSERT INTO orders"
  4. + "(uid"
  5. + ",uname"
  6. + ",email"
  7. + ",phone"
  8. + ",ordernum"
  9. + ",goods"
  10. + ",cost"
  11. + ",count"
  12. + ",coupon)"
  13. + "VALUES"
  14. + "(@uid"
  15. + ",@uname"
  16. + ",@email"
  17. + ",@phone"
  18. + ",@ordernum"
  19. + ",@goods"
  20. + ",@cost"
  21. + ",@count"
  22. + ",@coupon)";
  23. try
  24. {
  25. SqlCommand command = new SqlCommand();
  26.  
  27. command.Connection = connect;
  28. command.CommandType = CommandType.Text;
  29. command.CommandText = sql;
  30. command.Parameters.AddWithValue("@uid", tb_uid.Text);
  31. command.Parameters.AddWithValue("@uname", ???????);
  32. command.Parameters.AddWithValue("@email", tb_email.Text);
  33. command.Parameters.AddWithValue("@phone", tb_phone.Text);
  34. command.Parameters.AddWithValue("@ordernum", tb_ordernum.Text);
  35. command.Parameters.AddWithValue("@goods", tb_goods.Text);
  36. command.Parameters.AddWithValue("@cost", tb_cost.Text);
  37. command.Parameters.AddWithValue("@count", tb_count.Text);
  38. command.Parameters.AddWithValue("@coupon", tb_coupon.Text);
  39.  
  40. connect.Open();
  41. command.ExecuteNonQuery();
  42. // MessageBox.Show("Succes!");
  43.  
  44.  
  45. }
  46. catch (SqlException a)
  47. {
  48. Console.WriteLine(a);
  49. }
  50.  
  51. finally
  52. {
  53. connect.Close();
  54. View();
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement