Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Configuration;
- using System.Data.SqlClient;
- namespace Sample01
- {
- public partial class FrmSyohinSyokai : Form
- {
- public FrmSyohinSyokai()
- {
- InitializeComponent();
- }
- private void btnHyouji_Click(object sender, EventArgs e)
- {
- string connectionString = ConfigurationManager.ConnectionStrings["Db"].ConnectionString;
- using (SqlConnection connection = new SqlConnection(connectionString))
- {
- string sql = "select * from syohin";
- SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
- DataSet dataSet = new DataSet();
- adapter.Fill(dataSet, "syohin");
- DataTable dataTable = dataSet.Tables["syohin"];
- dgvSyohin.DataSource = dataTable;
- }
- }
- private void btnReset_Click(object sender, EventArgs e)
- {
- dgvSyohin.DataSource = null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement