Advertisement
StevanovicMilan

Vežba13

Jan 26th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.78 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.OleDb;
  11.  
  12. namespace Vezba_13_2018
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void glumceToolStripMenuItem_Click(object sender, EventArgs e)
  22.         {
  23.             using (OleDbConnection connection = new OleDbConnection(Properties.Settings.Default.B3DVDkolekcijaConnectionString))
  24.             {
  25.                 connection.Open();
  26.                 using (OleDbCommand command = new OleDbCommand("SELECT * FROM GLUMAC", connection))
  27.                 {
  28.                     using (OleDbDataReader reader = command.ExecuteReader())
  29.                     {
  30.                         textBox1.Clear();
  31.                         while(reader.Read())
  32.                         {
  33.                             textBox1.Text += reader.GetInt32(0);
  34.                             textBox1.Text += ". ";
  35.                             textBox1.Text += reader.GetString(1);
  36.                             textBox1.Text += ". ";
  37.                             textBox1.Text += reader.GetString(2);
  38.                             textBox1.Text += ". ";
  39.                             textBox1.Text += reader.GetDateTime(3);
  40.                             textBox1.Text += ". ";
  41.                             textBox1.Text += reader.GetString(4);
  42.                             textBox1.Text += ". ";
  43.                             textBox1.Text += "\r\n";
  44.                         }
  45.                     }
  46.                 }
  47.             }
  48.         }
  49.  
  50.         private void filmoveToolStripMenuItem_Click(object sender, EventArgs e)
  51.         {
  52.             using (OleDbConnection connection = new OleDbConnection(Properties.Settings.Default.B3DVDkolekcijaConnectionString))
  53.             {
  54.                 connection.Open();
  55.                 using (OleDbCommand command = new OleDbCommand("SELECT Naziv, OpisRadnje FROM FILM", connection))
  56.                 {
  57.                     using (OleDbDataReader reader = command.ExecuteReader())
  58.                     {
  59.                         textBox1.Clear();
  60.                         DataTable dataTable = new DataTable();
  61.                         dataTable.Load(reader);
  62.                         foreach(DataRow dataRow in dataTable.Rows)
  63.                         {
  64.                             textBox1.Text += string.Format("{0} - {1}", dataRow[0], dataRow[1]);
  65.                             textBox1.Text += "\r\n\r\n";
  66.                         }
  67.                         dataGridView1.DataSource = dataTable;
  68.                     }
  69.                 }
  70.             }
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement