12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace WindowsFormsApp1
- {
- public partial class Form1 : Form
- {
- SqlConnection connection;
- SqlCommand command;
- SqlDataAdapter adapter;
- DataTable table;
- public Form1()
- {
- InitializeComponent();
- connection = new SqlConnection("Server=Class31000;Database=aero;Trusted_connection=true;");
- command = new SqlCommand();
- command.Connection = connection;
- command.CommandType = CommandType.Text;
- adapter = new SqlDataAdapter(command);
- table = new DataTable();
- }
- private void ShowTable(string text)
- {
- dataGridView1.Columns.Clear();
- dataGridView1.DataSource = null;
- command.CommandText = text;
- table.Clear();
- adapter.Fill(table);
- dataGridView1.DataSource = table;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- ShowTable("Select * From Users");
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Form2 b = new Form2();
- b.Show();
- this.Hide();
- }
- }
- }
|