主键 A
其他 B
其他 C我在C#程序中先进行insert into 主键语句,然后再根据主键A,进行update其他(B、C)
但是我在 insert 进入主键时候,在sybase语句执行:
insert into records(A) values(90);插入主键sybase没报错,正常插入;
但是在程序里面执行就抛出异常:
[23000] [Sybase][ODBC Driver][Adaptive Server Anywhere]Integrity constraint violation: Primary key for table 'records' is not unique
说主键不唯一,但是insert into 语句成功插入,但是try catch语句就以上抛出错误。
sybase就是设置A为主键,直接执行SQL语句没错。
执行方法如下:
private void CreateCmd(string sql)
{
//方法1 this.cmd = new OdbcCommand();
this.checkTransaction();
this.cmd.Connection = this.openedCon;
this.cmd.CommandText = sql;
log.Info(sql); }
public int ExcSql(string sql)
{
this.CreateCmd(sql);
log.Info(this.cmd.ExecuteNonQuery());
return cmd.ExecuteNonQuery();
}
Conn.ExcSql(string.Format("insert into {0}({1}) values({2})", sTableName, sPrimaryKey, sqlno));
不知道哪里出问题,请大侠指教啊! sysbaseC
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货