Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Using Output parameter in ASP .Net Framework 3.5

Using Output parameter in ASP .Net Framework 3.5

Scheduled Pinned Locked Moved ASP.NET
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tina P
    wrote on last edited by
    #1

    Folks, I'm calling a stored proc from the built in login control in .Net. The stored proc is set up in such a way that it requires 4 parameters and one of them is a output parameter. I have a feeling I'm doing something wrong when I set up the output parameter in my code to be passed to the stored proc because the DBA (can see in his profiler my first 3 parameters coming in twice and that's what's causing problems. Here's the code I'm using to set up the output parameter. Can someone please verify it for me :)

    SqlCommand cmd = new SqlCommand("sp_ValidateUser", conn);
    cmd.CommandType = System.Data.CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@varUserName", UserName);
    cmd.Parameters.AddWithValue("@varUserPwd", Password);
    cmd.Parameters.AddWithValue("@varCaseNumber", this.txtBoxCaseNumber.Text);

        SqlParameter outputParam = new SqlParameter("@varISValid", SqlDbType.SmallInt);
        outputParam.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(outputParam);
          
        SqlDataReader Dr;
    
        Dr = cmd.ExecuteReader();
    
        while (Dr.Read())
        {
    
            if ((UserName == Dr\["UserName"\].ToString()) & (Password == Dr\["UserPwd"\].ToString()))
            {
                boolReturnValue = true;
            }
    
            Dr.Close();
    
            return boolReturnValue;
        }
    
        return boolReturnValue;
    
    }
    

    Thanks Tina

    A 1 Reply Last reply
    0
    • T Tina P

      Folks, I'm calling a stored proc from the built in login control in .Net. The stored proc is set up in such a way that it requires 4 parameters and one of them is a output parameter. I have a feeling I'm doing something wrong when I set up the output parameter in my code to be passed to the stored proc because the DBA (can see in his profiler my first 3 parameters coming in twice and that's what's causing problems. Here's the code I'm using to set up the output parameter. Can someone please verify it for me :)

      SqlCommand cmd = new SqlCommand("sp_ValidateUser", conn);
      cmd.CommandType = System.Data.CommandType.StoredProcedure;
      cmd.Parameters.AddWithValue("@varUserName", UserName);
      cmd.Parameters.AddWithValue("@varUserPwd", Password);
      cmd.Parameters.AddWithValue("@varCaseNumber", this.txtBoxCaseNumber.Text);

          SqlParameter outputParam = new SqlParameter("@varISValid", SqlDbType.SmallInt);
          outputParam.Direction = ParameterDirection.Output;
          cmd.Parameters.Add(outputParam);
            
          SqlDataReader Dr;
      
          Dr = cmd.ExecuteReader();
      
          while (Dr.Read())
          {
      
              if ((UserName == Dr\["UserName"\].ToString()) & (Password == Dr\["UserPwd"\].ToString()))
              {
                  boolReturnValue = true;
              }
      
              Dr.Close();
      
              return boolReturnValue;
          }
      
          return boolReturnValue;
      
      }
      

      Thanks Tina

      A Offline
      A Offline
      anilpal
      wrote on last edited by
      #2

      Hi, Can u also pls send yr SP code as well.

      Regards Anil Pal

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups