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 Ensyu01
- {
- public partial class FrmSyohinKensaku : Form
- {
- public FrmSyohinKensaku()
- {
- InitializeComponent();
- }
- private void btnKensaku_Click(object sender, EventArgs e)
- {
- string connectionString = ConfigurationManager.ConnectionStrings["Db"].ConnectionString;
- using (SqlConnection connection = new SqlConnection(connectionString))
- {
- string sql = "select SyohinCode,SyohinName,Price,BunruiName from syohin inner join Bunrui on syohin.BunruiNo = Bunrui.BunruiNo where SyohinName LIKE @sname";
- SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
- adapter.SelectCommand.Parameters.Add("@sname", SqlDbType.NVarChar);
- adapter.SelectCommand.Parameters["@sname"].Value = "%" + txtSyohinName.Text + "%";
- DataSet dataSet = new DataSet();
- adapter.Fill(dataSet, "syohin");
- DataTable dataTable = dataSet.Tables["syohin"];
- dvgSyohin.DataSource = dataTable;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement