namespace
Library
{
publicpartialclassFrmEditMember : Form
{
SqlDataAdapter adap = newSqlDataAdapter();
SqlConnection con = newSqlConnection("Data Source=localhost;Initial Catalog=Library;Integrated Security=True");
SqlCommand objsqlcommand = newSqlCommand();
DataSet dataset1 = newDataSet();
public FrmEditMember()
{
InitializeComponent();
}
privatevoid FrmEditMember_Load(object sender, EventArgs e)
{
adap.SelectCommand = newSqlCommand();
adap.SelectCommand.CommandText = "SELECT * FROM tbl_member ";
adap.SelectCommand.Connection = con;
adap.SelectCommand.CommandType = CommandType.Text;
con.Open();
adap.Fill(dataset1, "tbl_memberEdit");
con.Close();
dataGridView1.DataSource=dataset1;
dataGridView1.DataMember="tbl_memberEdit";
}
privatevoid txtSearch_TextChanged(object sender, EventArgs e)
{
adap.SelectCommand = newSqlCommand();
adap.SelectCommand.CommandText="SELECT * FROM tbl_member WHERE m_code LIKE '"+txtSearch.Text+"%'";
adap.SelectCommand.Connection = con;
adap.SelectCommand.CommandType = CommandType.Text;
con.Open();
dataset1.Tables[0].Clear();
adap.Fill(dataset1, "tbl_memberEdit");
con.Close();
dataGridView1.DataSource = dataset1;
dataGridView1.DataMember = "tbl_memberEdit";
}
privatevoid dataGridView1_Click(object sender, EventArgs e)
{
// این قسمت کد من مشکل داره
txtCodeOzviat.DataBindings.Add(
"Text",dataset1.Tables[0], "m_code");
}
privatevoid FrmEditMember_FormClosed(object sender, FormClosedEventArgs e)
{
Form1.frmopenmemberEdit= false;
}
}
}