SHARE
TWEET

Untitled

a guest Jun 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Windows.Forms;
  3. using Npgsql;
  4.  
  5. namespace Automated_WorkPlace_Library
  6. {
  7.     public partial class FormMain : Form
  8.     {
  9.         public NpgsqlConnection connection { get; set; } = null;
  10.         public FormMain()
  11.         {
  12.             InitializeComponent();
  13.         }
  14.  
  15.         private void FormMain_Load(object sender, EventArgs e)
  16.         {
  17.             connection = ConnectToDB("test", "123");        
  18.             connection.Open();
  19.  
  20.             var adapter_Books = new NpgsqlDataAdapter("select * from books", connection);
  21.             adapter_Books.Fill(DS_Books, "books");
  22.  
  23.             var adapter_Kinds = new NpgsqlDataAdapter("select * from kinds", connection);
  24.             adapter_Kinds.Fill(DS_Books, "kinds");
  25.  
  26.             DS_Books.Relations.Add("kind_of_book", DS_Books.Tables["kinds"].Columns["id"], DS_Books.Tables["books"].Columns["kind"]);
  27.  
  28.             DGV_Books.DataSource = DS_Books.Tables[0];
  29.  
  30.             connection.Close();
  31.  
  32.         }
  33.     }
  34. }
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