[求助] 有关数据访问的问题
我用的access数据库,怎么不能对它更新呢我的代码如下:
protected string sql_str = "Provider=sqloledb;server=localhost;database=user1";
OleDbConnection connection = new OleDbConnection(sql_str);
try
{
connection.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter("select * from titles", sql_str);
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
DataSet ds = new DataSet();
adapter.Fill(ds, "titles");
DataTable table = ds.Tables["titles"];
DataRow row = table.NewRow();
row["title_id"] = title_id.Text;
row["title"] = title.Text;
row["price"] = price.Text;
row["ytd_sales"] =ytd_sales.Text;
row["pubdate"] = dateTimePicker1.Value; //pubdate.Text;
table.Rows.Add(row);
adapter.Update(table);
}
catch (OleDbException ex)
{
}
finally
{
connection.Close();
}
运行没有错误提示!