zoukankan      html  css  js  c++  java
  • 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);        

    }

  • 相关阅读:
    算法
    nginx配置https
    IE中JS跳转丢失referer的问题
    js 调用字符串类型的 js语句
    移动端iOS中input聚焦不灵敏
    上传图片转换格式为base64并预览
    转:手机号脱敏
    转:Lodash之throttle(节流)与debounce(防抖)总结
    转:tinyMCE中图片的自定义上传
    chrome input 输入框去掉黄色
  • 原文地址:https://www.cnblogs.com/meroselove/p/1926904.html
Copyright © 2011-2022 走看看