DataAdapter.update()出错求助! c#
publicDataTableselect(stringname){stringoleDBComStr="SelectTOP1*FromTrimFormswhere[na...
public DataTable select(string name)
{
string oleDBComStr = "Select TOP 1 * From TrimForms where [name]='" + name + "';";
return select(oleDBComStr);
}
private DataTable select(string oleDBComStr)
{
string oleDBConStr = "provider=microsoft.ace.oledb.12.0;data source=" + DBAddress;
OleDbConnection oleDBCon = new OleDbConnection(oleDBConStr);
OleDbDataAdapter thisAdapter = new OleDbDataAdapter(oleDBComStr, oleDBConStr);
OleDbCommandBuilder oleDBCB = new OleDbCommandBuilder(thisAdapter);
oleDBCB.QuotePrefix = "[";
oleDBCB.QuoteSuffix = "]";
dt = new DataTable();
thisAdapter.Fill(dt);
return dt;
}
public void Save()
{
thisAdapter.Update(dt);
}
未处理 System.InvalidOperationException
Message="对于不返回任何键列信息的 SelectCommand,不支持 UpdateCommand 的动态 SQL 生成。"
求助呀!
还有那个dt上也看到有key呀
数据表库关系图 展开
{
string oleDBComStr = "Select TOP 1 * From TrimForms where [name]='" + name + "';";
return select(oleDBComStr);
}
private DataTable select(string oleDBComStr)
{
string oleDBConStr = "provider=microsoft.ace.oledb.12.0;data source=" + DBAddress;
OleDbConnection oleDBCon = new OleDbConnection(oleDBConStr);
OleDbDataAdapter thisAdapter = new OleDbDataAdapter(oleDBComStr, oleDBConStr);
OleDbCommandBuilder oleDBCB = new OleDbCommandBuilder(thisAdapter);
oleDBCB.QuotePrefix = "[";
oleDBCB.QuoteSuffix = "]";
dt = new DataTable();
thisAdapter.Fill(dt);
return dt;
}
public void Save()
{
thisAdapter.Update(dt);
}
未处理 System.InvalidOperationException
Message="对于不返回任何键列信息的 SelectCommand,不支持 UpdateCommand 的动态 SQL 生成。"
求助呀!
还有那个dt上也看到有key呀
数据表库关系图 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询