0
我想更新我的數據庫,當我運行我的項目並添加一個新行它的工作原理數據輸入到網格視圖,但它不會更新實際的數據庫。有什麼建議麼?更新數據庫c#
下面的代碼輸入到按鈕1:
DataRow dr = ds.Tables["details"].NewRow();
dr["Name"] = TextBox1.Text;
dr["Price"] = TextBox2.Text;
dr["Genre"] = TextBox3.Text;
ds.Tables["details"].Rows.Add(dr);
GridView1.DataSource = ds;
GridView1.DataBind();
localhost.Service myws = new localhost.Service();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
而且我使用Web服務:
public DataSet GetDetailsSet()
{
DataSet detailsSet = new DataSet();
string database = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|/shop.accdb;Persist Security Info=True";
OleDbConnection myConn = new OleDbConnection(database);
string queryStr = "SELECT * FROM details";
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(queryStr, myConn);
myConn.Open();
myDataAdapter.Fill(detailsSet, "Details");
myConn.Close();
return detailsSet;
}
我相信我需要在這個方法中添加某種方式更新,有什麼建議?