Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. Скрипт
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics.Eventing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using MySql.Data.MySqlClient;
  10. namespace BDBD
  11. {
  12. class Program
  13. {
  14. private const string constring = "Server=localhost;database=mydb;User=Maxim;password=123;CharSet=utf8;";
  15. private static readonly MySqlConnection con = new MySqlConnection(constring);
  16. static void Main(string[] args)
  17. {
  18. var css = new MySqlConnectionStringBuilder();
  19. con.Open();
  20. var bdex = new MySqlCommand("insert into `Клиент` values(32,89873982984,'Бурятов Михаил') on duplicate key update `Код клиента`=32", con);
  21. bdex.ExecuteNonQuery();
  22. var bdex2 = new MySqlCommand("select * from `Клиент`", con);
  23. var i=bdex2.ExecuteReader();
  24. Console.WriteLine(i);
  25. var N = i.FieldCount;
  26. while (i.Read())
  27. {
  28. var a = new Object[N];
  29. i.GetValues(a);
  30. Console.WriteLine(a[0]+" "+a[1]+" "+a[2]);
  31. }
  32. i.Close();
  33. bdex = new MySqlCommand("insert into `Товар`(`Код товара`,`Наименование`,`Цена`,`Код поставщика`) values (14,'Корм для рыбок',100,78) on duplicate key update `Код товара`=14", con);
  34. bdex.ExecuteNonQuery();
  35. bdex2 = new MySqlCommand("select `Цена` from `Товар` ", con);
  36. i=bdex2.ExecuteReader();
  37. Console.WriteLine(i);
  38. N = i.FieldCount;
  39. while (i.Read())
  40. {
  41. var a = new Object[N];
  42. i.GetValues(a);
  43. Console.WriteLine(a[0]);
  44. }
  45. i.Close();
  46. bdex2 = new MySqlCommand("select `Код товара` from `Склад` where `Количество` like '16' ", con);
  47. i=bdex2.ExecuteReader();
  48. Console.WriteLine(i);
  49. N = i.FieldCount;
  50. while (i.Read())
  51. {
  52. var a = new Object[N];
  53. i.GetValues(a);
  54. Console.WriteLine(a[0]);
  55. }
  56. i.Close();
  57. Console.WriteLine("{0} rows affected", i);
  58. con.Close();
  59. Console.ReadLine();
  60. }
  61. }
  62. } 
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement