namespace _173110007
{
public partial class frmEditData : Form
{
SqlConnection cnStudent = new SqlConnection("server=.;database=Students;integrated security=SSPI");
SqlDataAdapter dastudengt;
DataSet dsStudent;
public frmEditData()
{
InitializeComponent();
} private void button2_Click(object sender, EventArgs e)
{ }
private void UpdateDisplay()
{
dsStudent.Tables.Add(new DataTable("student"));
DataRow drv;
drv=this.dstudent1.Rows[this.BindingContext[this.dstudent1,"Student"].Position];
}
private void frmEditData_Load(object sender, EventArgs e)
{
string strsql="SELECT *FROM student";
dastudengt = new SqlDataAdapter(strsql,cnStudent);
dsStudent = new DataSet();
dastudengt.Fill(dsStudent,"student");
UpdateDisplay();
}
}
}
drv那里的dstudent1书上根本没有,不知道哪来的,求大神指导
this.BindingContext[this.dstudent1,"Student"].Position这个就是你要取表中哪一行
this.dstudent1应该是你界面上的一个控件