ADO .Net中的乐观并发 [英] Optimistic Concurrency in ADO .Net

查看:72
本文介绍了ADO .Net中的乐观并发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

当我执行下面提到的代码时,出现此错误:

Hi!

When I am executing the below mentioned code I am getting this error:

"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."


请帮助我解决此问题.


Please help me resolve this issue.

protected void Button1_Click(object sender, EventArgs e)
{
    string _connStr = ConfigurationManager.ConnectionStrings["practiceConnectionString"].ConnectionString;
    SqlConnection conn = new SqlConnection(_connStr);
    conn.Open();
    SqlCommand cmd = new SqlCommand("select * from PersonalDetail where id=3", conn);
    DataSet objDataset = new DataSet();
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    da.Fill(objDataset);
    SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(da);
    da.UpdateCommand = objCommandBuilder.GetUpdateCommand();
    objDataset.Tables[0].Rows[0][1] = "sashibhusan";
    da.Update(objDataset);
    conn.Close();
}





Thanks in advance!

推荐答案

在我脑海中,我可以想到两件事,这可能是错误的:
There are two things I can think of from the top of my head what could be wrong here:

  1. 所寻址的数据库不返回任何与主键以及正常结果集有关的元数据.
  2. 您的表PersonalDetail根本不包含任何主键.



请编辑您的问题,并添加您正在使用的数据库类型.

问候,

曼弗雷德(Manfred)



Please edit your question and add what kind of database you are using.

Regards,

Manfred


这篇关于ADO .Net中的乐观并发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆