annstasi

BD

Mar 31st, 2021 (edited)
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 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.  
  12. namespace bd
  13. {
  14. public partial class Form1 : Form
  15. {
  16. private SqlConnection sqlConnection = null;
  17. private SqlDataAdapter adapter = null;
  18. private DataTable table;
  19. public Form1()
  20. {
  21. InitializeComponent();
  22. }
  23.  
  24. private void Form1_Load(object sender, EventArgs e)
  25. {
  26. string ConnectionString = @"Data Source=xxx.xxx.xxx.xxx;Initial Catalog=db22204;User ID=User000;Password=**********;Integrated Security=False";
  27. sqlConnection = new SqlConnection(ConnectionString);
  28.  
  29. sqlConnection.Open();
  30.  
  31. adapter = new SqlDataAdapter("SELECT concat(txtClientSurname, ' ', txtClientName, ' ', txtClientSecondName) as 'ФИО клиента', intAccountTypeId as 'Тип счета', datAccountBegin as 'Дата открытия', txtAccountNumber as 'Номер счета' FROM tblAccount, tblClient WHERE tblAccount.intClientId = tblClient.intClientId", sqlConnection);
  32.  
  33. table = new DataTable();
  34.  
  35. adapter.Fill(table);
  36. dataGridView1.DataSource = table;
  37. dataGridView1.AutoResizeColumns();
  38.  
  39. sqlConnection.Close();
  40. }
  41.  
  42. private void button1_Click(object sender, EventArgs e)
  43. {
  44.  
  45. }
  46. }
  47. }
  48.  
Add Comment
Please, Sign In to add comment