标签:
/// <summary> /// 返回对应表的模拟自增字段值 /// </summary> /// <param name="tablename">表名</param> /// <returns>表的模拟自增字段值</returns> public decimal GetPKNum(string tablename) { switch (sqlType) { case "MSSQL2008": parameters = new List<DbParameter>(); parameters.Add(new SqlParameter("@table_name", SqlDbType.VarChar, 50)); parameters.Add(new SqlParameter("@key_value", SqlDbType.Decimal, 9)); parameters[0].Value = tablename; parameters[1].Direction = ParameterDirection.Output; break; case "Oracle": parameters = new List<DbParameter>(); parameters.Add(new OracleParameter(":tb_name", Oracle.ManagedDataAccess.Client.OracleDbType.Varchar2, 50)); parameters.Add(new OracleParameter(":key_value", Oracle.ManagedDataAccess.Client.OracleDbType.Decimal)); parameters[0].Value = tablename; parameters[0].Direction = ParameterDirection.Input; parameters[1].Direction = ParameterDirection.Output; break; default: break; } IDBHelper dbhelper = DBFactory.createDBHleper(); return dbhelper.RunProcedure(Utility.DB.PubConstant.ConnectionString,parameters, "up_get_table_key"); }
IDBHelper dbhelper = DBFactory.createDBHleper();是后台创建了一个dbhelp文件,如果当时是Oracle数据库 dbhelper 就为 OracleHelper文件
此oracle 存储过程具有两个参数,key_value 是返回参数out
Utility.DB.PubConstant.ConnectionString是数据库连接字符串
"up_get_table_key"为存储过程名称
标签:
原文地址:http://www.cnblogs.com/zcwry/p/5631984.html