• return @@identity


    use master

    go


    if exists(select name from sys.databases where name='Test_')

    drop database Test_

    go


    create database Test_

    go


    use Test_

    go


    if exists(select name from sys.objects where name='Table_')

    drop table Table_

    go


    create table Table_

    (

    ID int identity(100,1),

    Tname varchar(50)

    )

    go


    if exists(select name from sys.objects where name='Table_Proc')

    drop procedure Table_Proc

    go


    create procedure Table_Proc

    @Tname varchar(50),

    @Show varchar(100) output

    as

      insert into Table_(Tname) values(@Tname)

      set @Show='编号为:'+cast(@@identity as varchar(100))

    go
    declare @str varchar(100)

    execute Table_Proc '哈哈', @str output

    print @str

    go


    select * from Table_

    go

     protected void Page_Load(object sender, EventArgs e)

    {

    }
            
    SqlConnection Connection;

    private void SQLConnection()

    {            

    string str = "server=.;uid=sa;pwd=sa;database=Test_";            

    Connection = new SqlConnection(str);
     if (Connection.State == ConnectionState.Closed)

    {

      Connection.Open();

    }        

    }

     protected void btnAdd_Click(object sender, EventArgs e)        

    {            

      SQLConnection();
      SqlParameter[] Parms =

        {                

          new SqlParameter("@Tname",SqlDbType.VarChar,50),                

          new SqlParameter("@Show",SqlDbType.VarChar,100)            

        };


      Parms[0].Value = txtName.Text;            

      Parms[1].Direction = ParameterDirection.Output;
          SqlCommand Command = new SqlCommand("Table_Proc",Connection);            

      Command.CommandType = CommandType.StoredProcedure;
      Command.Parameters.AddRange(Parms);
          Command.ExecuteNonQuery();
           //Response.Write(Parms[1].Value.ToString());            

      Show(Parms[1].Value.ToString());        

    }

    protected void Show(string strShow)        

    {             

      string strScript= "<script>alert('" +strShow+ "')</script>";            

      this.Page.ClientScript.RegisterStartupScript(this.GetType(), "",strScript);        

    }

  • 相关阅读:
    架构笔记七
    架构笔记六
    架构笔记五
    架构笔记四
    python2与python3的区别
    萌新VRTK学习(四)攀爬系统
    萌新VRTK学习(三)物体的抓取
    萌新VRTK学习(二)移动
    萌新VRTK学习(一)VRTK的配置
    C#委托事件随笔
  • 原文地址:https://www.cnblogs.com/meroselove/p/1926904.html
Copyright © 2020-2023  润新知