zoukankan      html  css  js  c++  java
  • (五)SubSonic的存储过程操作

    一个不甚完善的存储过程:

    -----------------------------------存储过程代码开始------------------------------------

    -- ================================================
    -- 作用是代替自动增长型的ID,这样便于分表的维护
    -- ================================================

    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go

    ALTER PROCEDURE [dbo].[GenerateRUID]

    @tblName varchar(50),
    @currentnumber int OUTPUT

    AS
    SET NOCOUNT ON
    Declare @tempnumber int

    Begin

    SELECT @tempnumber= CurrentNumber
    FROM Ruid
    WHERE (TableName = @tblName)

    SET @tempnumber=@tempnumber+1
      
    Update Ruid
    SET CurrentNumber=@tempnumber
    Where TableName=@tblName

    SET @currentnumber=@tempnumber
    END

    -----------------------------------存储过程代码结束------------------------------------

    以下是利用SubSonic2.0使用该存储过程的代码:

    -----------------------------------代码开始------------------------------------

    public static int GetRUID(string tblName)
            {
                StoredProcedure spd = new StoredProcedure("GenerateRUID");
                spd.Command.AddParameter("@tblName", tblName);
                spd.Command.AddOutputParameter("@currentnumber");
                spd.Execute();
                int currentnumber = int.Parse(spd.OutputValues[0].ToString());
                return currentnumber;
            }

    -----------------------------------代码结束------------------------------------

    http://www.subsonicproject.com/

    引用:http://www.sim-zone.cn/?uid-6-action-viewspace-itemid-548

  • 相关阅读:
    [AGC019F] Yes or No
    [CF1063F]String Journey
    [Gym100490A] Approximation
    [ARC058C]Iroha and Haiku
    [互测题目]大括号树
    [UVA10859]放置街灯 Placing Lampposts
    PAT甲级1141PAT Ranking of Institutions
    PAT甲级1153Decode Registration Card of PAT
    使用Python语言通过PyQt5和socket实现UDP服务器
    数据结构-哈希
  • 原文地址:https://www.cnblogs.com/xiaopin/p/1721228.html
Copyright © 2011-2022 走看看