大侠请看错误提示及原代码
jlzjh 2002-01-07 09:02:41 System.InvalidOperationException: 对于不返回任何基表信息的 SelectCommand 不支持动态 SQL 生成。 at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) at ASP.dataset_aspx.Page_Load(Object Src, EventArgs E) in E:\Web_Program\lyxroot\WebApplication1\Date\dataset.aspx:line 29
protected void Page_Load(Object Src,EventArgs E)
{
try
{
OleDbConnection oledbConn = new OleDbConnection("Provider=;Persist Security Info=False;User ID=;Data Source=;Password=;Extended Properties=''");
OleDbDataAdapter CustomersDSCommand = new OleDbDataAdapter("select * from bbs",oledbConn);
OleDbCommandBuilder cb=new OleDbCommandBuilder(CustomersDSCommand); //必须要这句,才能用da.Update
oledbConn.Open();
myDataSet = new DataSet();
DataRow myCustomer;
CustomersDSCommand.Fill(myDataSet,"bbs");
myCustomer = myDataSet.Tables["bbs"].NewRow();
myCustomer["code"]="7";
myCustomer["name"]="per.zh";
myCustomer["sex"]="男";
myCustomer["age"]="18";
myDataSet.Tables["bbs"].Rows.Add(myCustomer);
CustomersDSCommand.Update(myDataSet,"bbs");
oledbConn.Close();
Response.Write("数据库操作完成");
}
catch(Exception e)
{
Response.Write(e.ToString());
}