SHARE
TWEET

Untitled

a guest Oct 17th, 2017 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE PROCEDURE my_pr1 (IN per VARCHAR(12), IN fd VARCHAR(60), IN fdo TEXT, IN pors INT)
  2. BEGIN
  3. INSERT INTO zakaz_active (persons, food, food_option, parth) VALUES (per, fd, fdo, tbln);END
  4.    
  5. using MySql.Data.MySqlClient;
  6.  
  7. namespace menu_mysql
  8. {
  9. public partial class menu : Form
  10. {
  11.  
  12.  
  13.     public menu()
  14.     {
  15.         InitializeComponent();
  16.     }
  17.  
  18.     MySqlConnection connect = new MySqlConnection("datasource=localhost;port=3306;Initial Catalog='testmenu';username=root;password=");
  19.  
  20.     private void textBox1_TextChanged(object sender, EventArgs e)
  21.     {
  22.  
  23.     }
  24.  
  25.     private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  26.     {
  27.  
  28.     }
  29.  
  30.     private void textBox2_TextChanged(object sender, EventArgs e)
  31.     {
  32.  
  33.     }
  34.  
  35.     private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  36.     {
  37.  
  38.     }
  39.  
  40.     private void button1_Click(object sender, EventArgs e)
  41.     {
  42.         MySqlParameter[] spr = new MySqlParameter[4];
  43.         spr[0] = new MySqlParameter("per", SqlDbType.VarChar);
  44.         spr[0].Value = textBox1.Text;
  45.  
  46.         spr[1] = new MySqlParameter("fd", SqlDbType.VarChar);
  47.         spr[1].Value = comboBox1.Text;
  48.  
  49.         spr[2] = new MySqlParameter("fdo", SqlDbType.Text);
  50.         spr[2].Value = textBox2.Text;
  51.  
  52.         spr[3] = new MySqlParameter("pors", SqlDbType.Int);
  53.         spr[3].Value = comboBox2.Text;
  54.  
  55.         MySqlCommand comand = new MySqlCommand();
  56.  
  57.         comand.Connection = connect;
  58.         comand.CommandType = CommandType.StoredProcedure;
  59.         comand.CommandText = "my_sp1";
  60.  
  61.         comand.Parameters.AddRange(spr);
  62.  
  63.         connect.Open();
  64.         if (comand.ExecuteNonQuery() == 1)
  65.         {
  66.             MessageBox.Show("Yes");
  67.         }
  68.         else
  69.         {
  70.             MessageBox.Show("No");
  71.         }
  72.         connect.Close();
  73.     }
  74.    
  75. if (comand.ExecuteNonQuery() == 1)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top