我的本意是:在DataSet表中把一条特定的记录修改一下,然后Update到数据库中去
部分代码:
//BaseDoAccess是我定义的静态类,里面放的基本数据库操作函数,应该没有问题
sqlStr = "select * from PersonRecords where MovieNum ='"+oldId+"'";
OleDbDataAdapter sda=new OleDbDataAdapter(sqlStr,BaseDoAccess.connStr);
DataSet ds=new DataSet();
OleDbCommandBuilder GoodCB = new OleDbCommandBuilder(sda);
sda.Fill(ds,"personRecords");
int iRow = ds.Tables["personRecords"].Rows.Count;
for(int i =0;i<iRow;i++)
{
if(ds.Tables["personRecords"].Rows[i]["MovieNum"].ToString() == oldId)
{
ds.Tables["personRecords"].Rows[i]["MovieNum"]=nowId;
ds.Tables["personRecords"].Rows[i]["MovieShortName"]=nowShortName;
ds.Tables["personRecords"].Rows[i]["LentDate"]=System.DateTime.Today;
ds.Tables["personRecords"].Rows[i]["ReturnDate"]=System.DateTime.Today;
if(errorNum==1)
{
MessageBox.Show("换碟成功!","告诉您!",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
MessageBox.Show("操作失败,请检查输入信息","提醒您!",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
编译器包错:其他信息: 对于不返回任何键列信息的 SelectCommand 不支持 UpdateCommand 的动态 SQL 生成。
部分代码:
//BaseDoAccess是我定义的静态类,里面放的基本数据库操作函数,应该没有问题
sqlStr = "select * from PersonRecords where MovieNum ='"+oldId+"'";
OleDbDataAdapter sda=new OleDbDataAdapter(sqlStr,BaseDoAccess.connStr);
DataSet ds=new DataSet();
OleDbCommandBuilder GoodCB = new OleDbCommandBuilder(sda);
sda.Fill(ds,"personRecords");
int iRow = ds.Tables["personRecords"].Rows.Count;
for(int i =0;i<iRow;i++)
{
if(ds.Tables["personRecords"].Rows[i]["MovieNum"].ToString() == oldId)
{
ds.Tables["personRecords"].Rows[i]["MovieNum"]=nowId;
ds.Tables["personRecords"].Rows[i]["MovieShortName"]=nowShortName;
ds.Tables["personRecords"].Rows[i]["LentDate"]=System.DateTime.Today;
ds.Tables["personRecords"].Rows[i]["ReturnDate"]=System.DateTime.Today;
if(errorNum==1)
{
MessageBox.Show("换碟成功!","告诉您!",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
MessageBox.Show("操作失败,请检查输入信息","提醒您!",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
编译器包错:其他信息: 对于不返回任何键列信息的 SelectCommand 不支持 UpdateCommand 的动态 SQL 生成。
解决方案 »
- C#如限制用户只能输入字母和数字
- 一个SQL语句的问题
- 请问此方法能够得到具体的数据集吗?不会被Dispose()清空吧??
- bmp图片转化为JPEG图片 求教。在线等待
- C# 使用EPL命令通过USB接口打印条码?
- 怎么写这个正则表达式?
- 我写的划线方法,怎么窗体创建时不运行呢?
- HttpWebRequest如何获取服务器程序运行时错误信息?
- 关于datatable datarow datacolumn的问题~~~~~~~~~~~急
- 谁有vs.net的安装的CDKey?
- 给个Borland Together 2005 for VS.net正式版的下载地址吧。
- DataGrid + DataSet
http://blog.csdn.net/zhzuo/archive/2004/08/06/67037.aspx