Guest User

Untitled

a guest
Apr 26th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. while (rdr.Read())
  2. {
  3. int promised_date = (int)(rdr.GetValue(0));
  4.  
  5. string strClientReference = (rdr.GetValue(2).ToString());
  6. string strJobCategory = (rdr.GetValue(3).ToString());
  7. string datCommisioned = (rdr.GetValue(4).ToString());
  8. string datPromisedDelivery = (rdr.GetValue(5).ToString());
  9.  
  10.  
  11. if (this.OpenConnection() == true)
  12. {
  13. string querynew = "INSERT INTO jobs_table (nJobNumber,strClientName,strClientReference,strJobCategory,datCommisioned,datPromisedDelivery) VALUES ("+promised_date+",'"+strClientName+"','"+strClientReference+"','"+strJobCategory+"','"+datCommisioned+"','"+datPromisedDelivery+"' )";//yeyyy why only few?
  14.  
  15. MySqlCommand cmd = new MySqlCommand(querynew, connection);
  16. cmd.ExecuteNonQuery();
  17.  
  18. this.CloseConnection();
  19. }
  20. }
  21.  
  22. while (rdr.Read())
  23. {
  24. int promised_date = (int)(rdr.GetValue(0));
  25. string strClientName = (rdr.GetValue(1).ToString());
  26. string strClientReference = (rdr.GetValue(2).ToString());
  27. string strJobCategory = (rdr.GetValue(3).ToString());
  28. string datCommisioned = (rdr.GetValue(4).ToString());
  29. string datPromisedDelivery = (rdr.GetValue(5).ToString());
  30.  
  31. if (this.OpenConnection() == true)//closing parenthesis
  32. {
  33. // query using parameter names
  34. string querynew = "INSERT INTO jobs_table "
  35. + "(nJobNumber,strClientName,strClientReference,strJobCategory,datCommisioned,datPromisedDelivery)"
  36. + "VALUES (@PromisedDate, @ClientName, @ClientReference, @JobCategory, @Commisioned, @PromisedDelivery)";
  37.  
  38. MySqlCommand cmd = new MySqlCommand(querynew, connection);
  39.  
  40. // add parameters and their value
  41. cmd.Parameters.AddWithValue("@PromisedDate", promised_date);
  42. cmd.Parameters.AddWithValue("@ClientName", strClientName);
  43. cmd.Parameters.AddWithValue("@ClientReference", strClientReference);
  44. cmd.Parameters.AddWithValue("@JobCategory", strJobCategory);
  45. cmd.Parameters.AddWithValue("@Commissioned", datCommissioned);
  46. cmd.Parameters.AddWithValue("@PromisedDelivery", datPromisedDelivery);
  47.  
  48. cmd.ExecuteNonQuery();
  49.  
  50. this.CloseConnection();
  51. }
  52. }
Add Comment
Please, Sign In to add comment