Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SqlClient;
  11. using MySql.Data;
  12. namespace Imenik
  13. {
  14.     public partial class dodavanje : Form
  15.     {
  16.         public dodavanje()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void dodaj_Click(object sender, EventArgs e)
  22.         {
  23.  
  24.  
  25.    
  26.                 string Query="insert into imenik.imenik (Ime, Prezime,  Broj telefona, Opis) values('"+this.ime_txt.Text+"' , '"+this.prezime_txt.Text+"' , '"+this.brojtel_txt.Text+"' , '"+this.opis_txt.Text+"') ;";
  27.          string constring = "datasource=localhost; port=3306; username=root; password=123";
  28.          
  29.             MySQLConnection con = new MySQLConnection();
  30.             MySql.Data.MySqlClient.MySqlCommand cmdDataBase = new MySql.Data.MySqlClient.MySqlCommand(Query, con);
  31.            
  32.             try{
  33.  
  34.                 con.Connect();
  35.                 cmdDataBase.ExecuteNonQuery();
  36.                 MessageBox.Show("Sacuvano");
  37.  
  38.  
  39.             }catch(Exception ex){
  40.                 MessageBox.Show(ex.Message);
  41.             }
  42.     finally {
  43.     con.Close();
  44. }
  45.  
  46.              
  47.            
  48.     }
  49.  
  50.         private void dodavanje_Load(object sender, EventArgs e)
  51.         {
  52.        
  53.         }
  54.  
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement