zoukankan      html  css  js  c++  java
  • .net 获取 存储过程的输出参数

    存储过程: 做的就是 返回最后一次插入的标识列 id值

    create proc pa2
    
    @id int output
    as
    insert into a(name) values('5')
    set @id=@@identity

    表: id 是标识列 ,

    image

    后台代码: 

     string cons = ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString();
    
            using (SqlConnection con=new SqlConnection(cons))
            {
                if (con.State==ConnectionState.Closed)
                {
                    con.Open();
                    
                }
    
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "pa2";
    
                cmd.Parameters.Add(new SqlParameter("@id",DbType.Int32));
    
                cmd.Parameters["@id"].Direction = ParameterDirection.Output;
    
                cmd.ExecuteNonQuery();
                con.Close();
                Response.Write(cmd.Parameters["@id"].Value.ToString());
                
    
            }

    效果:

    image

  • 相关阅读:
    dede 专题的调用
    dede织梦CMS文件夹目录结构
    [转]Dedecms备份还原网站有效方法
    dede入侵步骤
    dede限制标题长度后,鼠标移到标题,不显示完整的锚文本标题解决方法
    dede列表缩图中,给缩图添加alt锚文本信息的方法
    dede织梦_高级功能function扩展-dede @me
    《DSP using MATLAB》示例Example4.8
    《DSP using MATLAB》示例Example4.7
    《DSP using MATLAB》示例Example4.6
  • 原文地址:https://www.cnblogs.com/soundcode/p/2680001.html
Copyright © 2011-2022 走看看