呵呵,公司不准用qq
public DataSet dataSet;
public int index=0;
private Form2 Frm;
private void Form1_Load(object sender, System.EventArgs e)
{
SqlConnection conn=new SqlConnection("Server=purana;Database=demo;Integrated Security=SSPI");
SqlDataAdapter ada=new SqlDataAdapter("Select * From 工作室",conn);
conn.Open();
dataSet=new DataSet();
ada.Fill(dataSet,"工作室");
conn.Close();
dataGrid1.DataSource=dataSet.Tables[0];
}
private void dataGrid1_DoubleClick(object sender, System.EventArgs e)
{
index=dataGrid1.CurrentRowIndex;
if (Frm == null)
{
Frm = new Form2();
}
Frm.textBox1.Text=dataSet.Tables[0].Rows[index]["编号"].ToString();
Frm.textBox2.Text=dataSet.Tables[0].Rows[index]["姓名"].ToString();
Frm.textBox3.Text=dataSet.Tables[0].Rows[index]["年龄"].ToString();
Frm.textBox4.Text=dataSet.Tables[0].Rows[index]["性别"].ToString();
Frm.textBox5.Text=dataSet.Tables[0].Rows[index]["部门"].ToString();
Frm.Show();
}