Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Скрипт
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.Eventing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MySql.Data.MySqlClient;
- namespace BDBD
- {
- class Program
- {
- private const string constring = "Server=localhost;database=mydb;User=Maxim;password=123;CharSet=utf8;";
- private static readonly MySqlConnection con = new MySqlConnection(constring);
- static void Main(string[] args)
- {
- var css = new MySqlConnectionStringBuilder();
- con.Open();
- var bdex = new MySqlCommand("insert into `Клиент` values(32,89873982984,'Бурятов Михаил') on duplicate key update `Код клиента`=32", con);
- bdex.ExecuteNonQuery();
- var bdex2 = new MySqlCommand("select * from `Клиент`", con);
- var i=bdex2.ExecuteReader();
- Console.WriteLine(i);
- var N = i.FieldCount;
- while (i.Read())
- {
- var a = new Object[N];
- i.GetValues(a);
- Console.WriteLine(a[0]+" "+a[1]+" "+a[2]);
- }
- i.Close();
- bdex = new MySqlCommand("insert into `Товар`(`Код товара`,`Наименование`,`Цена`,`Код поставщика`) values (14,'Корм для рыбок',100,78) on duplicate key update `Код товара`=14", con);
- bdex.ExecuteNonQuery();
- bdex2 = new MySqlCommand("select `Цена` from `Товар` ", con);
- i=bdex2.ExecuteReader();
- Console.WriteLine(i);
- N = i.FieldCount;
- while (i.Read())
- {
- var a = new Object[N];
- i.GetValues(a);
- Console.WriteLine(a[0]);
- }
- i.Close();
- bdex2 = new MySqlCommand("select `Код товара` from `Склад` where `Количество` like '16' ", con);
- i=bdex2.ExecuteReader();
- Console.WriteLine(i);
- N = i.FieldCount;
- while (i.Read())
- {
- var a = new Object[N];
- i.GetValues(a);
- Console.WriteLine(a[0]);
- }
- i.Close();
- Console.WriteLine("{0} rows affected", i);
- con.Close();
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement