日期:2014-05-18 浏览次数:20882 次
int rows = -1; string query = "INSERT Into LevelSpace(LevelNumber1, LevelNumber2, LevelNumber3, LevelNumber4, LevelNumber5, LevelNumber6, createdby, updatedby, createddate, updateddate) VALUES(@custLevel, @prodLevel, @regionLevel, NULL, NULL, NULL, 1, 1, getdate(), getdate());select @LevelSpaceID=@@identity from LevelSpace"; SqlCommand sc = new SqlCommand(query,getSqlConnection()); int cmd_to_value; bool has_value = Int32.TryParse(ConfigurationManager.AppSettings["R90.Plan-CreateLevelSpace"] , out cmd_to_value); if(!has_value) sc.CommandTimeout = _defaultCmdTO; else sc.CommandTimeout = (cmd_to_value < 30) ? 30 : cmd_to_value; if ( custLevel != null ) sc.Parameters.Add("@custLevel",SqlDbType.Int,4).Value = (int)custLevel; else sc.Parameters.Add("@custLevel",SqlDbType.Int,4).Value = DBNull.Value; if ( prodLevel != null ) sc.Parameters.Add("@prodLevel",SqlDbType.Int,4).Value = (int)prodLevel; else sc.Parameters.Add("@prodLevel",SqlDbType.Int,4).Value = DBNull.Value; if ( regionLevel != null ) sc.Parameters.Add("@regionLevel",SqlDbType.Int,4).Value = (int)regionLevel; else sc.Parameters.Add("@regionLevel",SqlDbType.Int,4).Value = DBNull.Value; sc.Parameters.Add("@LevelSpaceID",SqlDbType.Int,4).Direction = ParameterDirection.Output; SqlPerf sqpe = SqlPerf.CreateInstance("CreateLevelSpace",query); SqlDataReader dr = null; try { startup(sc,sqpe, false ); rows = sc.ExecuteNonQuery(); }
declare @LevelSpaceID int INSERT Into LevelSpace(LevelNumber1, LevelNumber2, LevelNumber3, LevelNumber4, LevelNumber5, LevelNumber6, createdby, updatedby, createddate, updateddate) VALUES(1, 1, 1, NULL, NULL, NULL, 1, 1, getdate(), getdate()); select @LevelSpaceID=@@identity from LevelSpace print @LevelSpaceID