You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.3 KiB
63 lines
1.3 KiB
using PSqlSeverWrapper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace MSSQLServer_Form
|
|
{
|
|
public partial class MainForm : Form
|
|
{
|
|
private SqlConnection connection;
|
|
private SqlDataAdapter adapter;
|
|
|
|
private DataTable table;
|
|
|
|
public MainForm()
|
|
{
|
|
InitializeComponent();
|
|
InitInstance();
|
|
}
|
|
|
|
private void InitInstance()
|
|
{
|
|
PSqlServer.ServerName = "peacecloud.synology.me,21433";
|
|
PSqlServer.DatabaseName = "Study";
|
|
PSqlServer.UserId = "study";
|
|
PSqlServer.Password = "Study123$";
|
|
|
|
connection = PSqlServer.Connection;
|
|
connection.Open();
|
|
|
|
string query = "SELECT * FROM member";
|
|
adapter = PSqlServer.GetAdapterSelectQuery(connection, query);
|
|
|
|
table = new DataTable();
|
|
adapter.Fill(table);
|
|
|
|
if (table != null)
|
|
memberGrid.DataSource = table;
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if (connection.State != ConnectionState.Open)
|
|
return;
|
|
|
|
adapter.Update(table);
|
|
table.AcceptChanges();
|
|
}
|
|
|
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
if (connection.State == ConnectionState.Open)
|
|
connection.Close();
|
|
}
|
|
}
|
|
}
|
|
|