it is no longer usable和字符串格式不正确
这些情况是怎么回事? --------------------编程问答-------------------- 方法过时了,用新版本的方法就行了 --------------------编程问答-------------------- 字符串格式不正确啊, --------------------编程问答-------------------- 字符串格式不正确...那就得把代码拿出来了 --------------------编程问答--------------------你说的是什么方法? --------------------编程问答-------------------- This OracleTransaction has completed; it is no longer usable.
代码随后帖出 --------------------编程问答--------------------
--------------------编程问答-------------------- i=3时报以上错误, 前三次都没问题,很费解,很郁闷呐 --------------------编程问答-------------------- OracleTransaction 已经提交了,这个对象已经销毁了。
private int SaveBaseObject()
{
/*-----------------增加对象基本信息SQL语句----------------------*/
if (CheckBaseData(this) != 0) return -2;
SqlBase sb = new SqlBase("CostObjectBaseUpdate");
sb.AddParms(":dep_id",System.Data.OracleClient.OracleType.Int32,this.DepId.ToString(),1);
sb.AddParms(":Id",System.Data.OracleClient.OracleType.Int32,this.ID.ToString(),1);
sb.AddParms(":cd",System.Data.OracleClient.OracleType.VarChar,this.CD,0);
sb.AddParms(":nm",System.Data.OracleClient.OracleType.VarChar,this.Name,0);
sb.AddParms(":describe",System.Data.OracleClient.OracleType.VarChar,this.Describe,0);
sb.AddParms(":account_method",System.Data.OracleClient.OracleType.Char,this.AccountMethod,0);
sb.AddParms(":otype",System.Data.OracleClient.OracleType.VarChar,this.OType,0);
sb.AddParms(":used",System.Data.OracleClient.OracleType.Char,this.Used,0);
// sb.AddParms(":account_method",System.Data.OracleClient.OracleType.Char,this.AccountMethod,0);
sb.AddParms(":dataflag",System.Data.OracleClient.OracleType.Int32,this.DataFlag.ToString(),1);
myDb.AddNoQuerySQL(sb);
/*-------------------删除对象已存在的类型---------------------*/
sb = new SqlBase("CostObjectsBaseAdelete");
sb.AddParms(":dep_id",System.Data.OracleClient.OracleType.Int32,this.DepId.ToString(),1);
sb.AddParms(":id",System.Data.OracleClient.OracleType.Int32,this.ID.ToString(),1);
myDb.AddNoQuerySQL(sb);
/*------------------增加对象类型SQL语句------------------------*/
for (int i=0;i<objectList.Count;i++)
{
sb = new SqlBase("CostObjectsBaseinsert");
sb.AddParms(":dep_id",System.Data.OracleClient.OracleType.Int32,this.DepId.ToString(),1);
sb.AddParms(":Id",System.Data.OracleClient.OracleType.Int32,this.ID.ToString(),1);
sb.AddParms(":mat_tec_equ_id",System.Data.OracleClient.OracleType.Int32,objectList[i].ToString(),1);
sb.AddParms(":used",System.Data.OracleClient.OracleType.Char,"Y",0);
myDb.AddNoQuerySQL(sb);
}
/*-----------------删除该对象的结构的SQL------------------------*/
sb = new SqlBase("CostStrucObjectdelete");
sb.AddParms(":object_id",System.Data.OracleClient.OracleType.Int32,this.ID.ToString(),1);
myDb.AddNoQuerySQL(sb);
/*--------------------增加对象结构的SQL-------------------------*/
for (int i=0;i<this.CostBaseItemCollection.Count;i++)
{
if (this.CostBaseItemCollection[i].CostBaseResCollection.Count<=0)
{
sb = new SqlBase("CostStrucBaseinsert");
sb.AddParms(":dep_id",System.Data.OracleClient.OracleType.Int32,this.DepId.ToString(),1);
sb.AddParms(":object_id",System.Data.OracleClient.OracleType.Int32,this.ID.ToString(),1);
sb.AddParms(":item_id",System.Data.OracleClient.OracleType.Int32,this.CostBaseItemCollection[i].ID.ToString(),1);
sb.AddParms(":res_id",System.Data.OracleClient.OracleType.Int32,"0",1);
sb.AddParms(":com_type",System.Data.OracleClient.OracleType.Int32,"0",0);
sb.AddParms(":Res_ration",System.Data.OracleClient.OracleType.Int32,"0",1);
sb.AddParms(":Unit_id",System.Data.OracleClient.OracleType.Int32,"0",1);
sb.AddParms(":Mhration_id",System.Data.OracleClient.OracleType.Int32,"0",1);
sb.AddParms(":Com_flag",System.Data.OracleClient.OracleType.Int32,"0",0);
sb.AddParms(":Up_flag",System.Data.OracleClient.OracleType.Int32,"0",0);
myDb.AddNoQuerySQL(sb);
}
else
{
for (int j=0;j<this.CostBaseItemCollection[i].CostBaseResCollection.Count;j++)
{
CostBaseRes cbr = this.CostBaseItemCollection[i].CostBaseResCollection[j];
sb = new SqlBase("CostStrucBaseinsert");
sb.AddParms(":dep_id",System.Data.OracleClient.OracleType.Int32,this.DepId.ToString(),1);
sb.AddParms(":object_id",System.Data.OracleClient.OracleType.Int32,this.ID.ToString(),1);
sb.AddParms(":item_id",System.Data.OracleClient.OracleType.Int32,this.CostBaseItemCollection[i].ID.ToString(),1);
sb.AddParms(":res_id",System.Data.OracleClient.OracleType.Int32,cbr.ID.ToString(),1);
sb.AddParms(":com_type",System.Data.OracleClient.OracleType.Int32,cbr.CostBaseStruc.ComType,0);
sb.AddParms(":Res_ration",System.Data.OracleClient.OracleType.Number,cbr.CostBaseStruc.ResRation.ToString(),1);
sb.AddParms(":Unit_id",System.Data.OracleClient.OracleType.Int32,cbr.CostBaseStruc.UnitId.ToString(),1);
sb.AddParms(":Mhration_id",System.Data.OracleClient.OracleType.Int32,cbr.CostBaseStruc.MhrationId.ToString(),1);
sb.AddParms(":Com_flag",System.Data.OracleClient.OracleType.Int32,cbr.CostBaseStruc.ComFlag,0);
sb.AddParms(":Up_flag",System.Data.OracleClient.OracleType.Int32,cbr.CostBaseStruc.UpFlag,0);
myDb.AddNoQuerySQL(sb);
}
}
}
try
{
myDb.oraExecuteListNoQuerys();
return 0;
}
catch (DBException de)
{
dbErrorCode = de.DbCode;
dbErrorMessage = de.DbDescribe;
return -1;
}
}
myDb.AddNoQuerySQL(sb);这里是如何实现的? --------------------编程问答-------------------- 可能是连接数据超时了吧。或者你的OracleTransaction 是自动提交。 --------------------编程问答-------------------- This OracleTransaction has completed; it is no longer usable.
...只贴了后半句,误解成方法过时了... --------------------编程问答--------------------
public void AddNoQuerySQL(SqlBase sb)
{
_SqlBaseCollection.Add(sb);
}
public int Add(SqlBase sb)
{
return List.Add(sb);
}
是这两个方法实现的 --------------------编程问答-------------------- 你操作数据库是如何实现的?
这两个方法看不出问题的.你什么地方用到OracleTransaction --------------------编程问答-------------------- 前面问题答案是因为我关闭了连接,后面的字符串格式不正确怎么都找不出来,费劲 --------------------编程问答-------------------- 是你添加参数的地方有问题吧
补充:.NET技术 , C#