//連線你的資料庫
stringconnstr="server=.;uid=sa;pwd=sa;database=sc";
using(SqlConnectionconn=newSqlConnection(connstr))
{
conn.Open();
DataSetds=newDataSet();
SqlDataAdapterda=newSqlDataAdapter(sqlsel,conn);
da.Fill(ds,"coust");
DataTabledt=ds.Tables["coust"];
conn.Close();
returndt;
//TODO:這行程式碼將資料載入到表“studentDataSet.studentinfo”中。您可以根據需要移動或移除它。
//this.studentinfoTableAdapter.Fill(this.studentDataSet.studentinfo);
//資料繫結
stringsqlsel="select*fromstudentinfo";
DataTabledt=bangding(sqlsel);
cmAmend=(CurrencyManager)BindingContext[dt];
this.dataGridView1.DataSource=dt;
this.textBox1.DataBindings.Add("text",dt,"sno");
this.textBox2.DataBindings.Add("text",dt,"sname");
this.textBox3.DataBindings.Add("text",dt,"ssex");
this.textBox4.DataBindings.Add("text",dt,"sage");
this.textBox5.DataBindings.Add("text",dt,"sclass");
this.textBox6.DataBindings.Add("text",dt,"sdept");
this.textBox7.DataBindings.Add("text",dt,"saddress");
this.textBox8.DataBindings.Add("text",dt,"sphone");
this.textBox9.DataBindings.Add("text",dt,"sqq");
//連線你的資料庫
stringconnstr="server=.;uid=sa;pwd=sa;database=sc";
using(SqlConnectionconn=newSqlConnection(connstr))
{
conn.Open();
DataSetds=newDataSet();
SqlDataAdapterda=newSqlDataAdapter(sqlsel,conn);
da.Fill(ds,"coust");
DataTabledt=ds.Tables["coust"];
conn.Close();
returndt;
//TODO:這行程式碼將資料載入到表“studentDataSet.studentinfo”中。您可以根據需要移動或移除它。
//this.studentinfoTableAdapter.Fill(this.studentDataSet.studentinfo);
//資料繫結
stringsqlsel="select*fromstudentinfo";
DataTabledt=bangding(sqlsel);
cmAmend=(CurrencyManager)BindingContext[dt];
this.dataGridView1.DataSource=dt;
this.textBox1.DataBindings.Add("text",dt,"sno");
this.textBox2.DataBindings.Add("text",dt,"sname");
this.textBox3.DataBindings.Add("text",dt,"ssex");
this.textBox4.DataBindings.Add("text",dt,"sage");
this.textBox5.DataBindings.Add("text",dt,"sclass");
this.textBox6.DataBindings.Add("text",dt,"sdept");
this.textBox7.DataBindings.Add("text",dt,"saddress");
this.textBox8.DataBindings.Add("text",dt,"sphone");
this.textBox9.DataBindings.Add("text",dt,"sqq");