|
|
|
|
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";
|
|
|
|
|
|
|
|
|
|
// 여러 테이블에는 자동으로 동적쿼리 생성 불가
|
|
|
|
|
//string query = @"SELECT * FROM member AS m
|
|
|
|
|
// JOIN member_hr AS h ON m.guid = h.guid";
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|