Advertisement
Velja_Programer

Stadioni

Jun 7th, 2020
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace B5_Veljko
  13. {
  14.     public partial class Form3 : Form
  15.     {
  16.         SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-BEDE3AM\SQLEXPRESS;Initial Catalog=B5;Integrated Security=True");
  17.         public Form3()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void Form3_Load(object sender, EventArgs e)
  23.         {
  24.  
  25.         }
  26.  
  27.         private void button2_Click(object sender, EventArgs e)
  28.         {
  29.             this.Close();
  30.         }
  31.  
  32.         private void button1_Click(object sender, EventArgs e)
  33.         {
  34.             string k = "select i.Ime,i.Prezime,k.NazivKluba" +
  35.                         " from Pozicija_igraca p,Igrac i, Klub k" +
  36.                         " where p.PozicijaID = i.PozicijaID and i.KlubID = k.KlubID;" +
  37.                         " and k.GradID="+comboBox1.SelectedValue;
  38.             try
  39.             {
  40.                 con.Open();
  41.                 SqlCommand cmd = new SqlCommand(k, con);
  42.                 DataTable T = new DataTable();
  43.                 SqlDataAdapter A = new SqlDataAdapter(cmd);
  44.                 A.Fill(T);
  45.                 dataGridView1.DataSource = T;
  46.                
  47.             }
  48.             catch (Exception x)
  49.             {
  50.                 MessageBox.Show(x.Message);
  51.                 throw;
  52.             }
  53.             finally
  54.             {
  55.                 if (con.State == ConnectionState.Open) con.Close();
  56.             }
  57.  
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement