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. Asp.Net / SQL2005 Stored Procedure Update Problem

Asp.Net / SQL2005 Stored Procedure Update Problem

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-nethelpquestion
3 Posts 3 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.
  • M Offline
    M Offline
    munklefish
    wrote on last edited by
    #1

    Hi, Im using a stroed procedure to update records in a SQL2005 DB. To send info to the procedure i run something similar to this:

    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@email", tbxUsername.Text);
    cmd.Parameters.AddWithValue("@password", tbxPass.Text);
    cmd.ExecuteNonQuery();

    Under certain circumstance i wont want to update the @password field. Is this possible, if so how? Or do i need to use a seperate stored procedure which doesnt mention the field(s) which shouldn't be updated? Thanks.

    C A 2 Replies Last reply
    0
    • M munklefish

      Hi, Im using a stroed procedure to update records in a SQL2005 DB. To send info to the procedure i run something similar to this:

      cmd.CommandType = CommandType.StoredProcedure;
      cmd.Parameters.AddWithValue("@email", tbxUsername.Text);
      cmd.Parameters.AddWithValue("@password", tbxPass.Text);
      cmd.ExecuteNonQuery();

      Under certain circumstance i wont want to update the @password field. Is this possible, if so how? Or do i need to use a seperate stored procedure which doesnt mention the field(s) which shouldn't be updated? Thanks.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      The logic is entirely up to you, since I don't know the detail I can't guide you on what is the best course of action. I would say that if the code will do different things then it should be in a different sproc. Does the current sproc do more than update the password? If so what? And what circumstances don't you want to sproc to update the password. And this question belongs in the database forum.

      Man who stand on hill with mouth open wait long time for roast duck to drop in

      1 Reply Last reply
      0
      • M munklefish

        Hi, Im using a stroed procedure to update records in a SQL2005 DB. To send info to the procedure i run something similar to this:

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@email", tbxUsername.Text);
        cmd.Parameters.AddWithValue("@password", tbxPass.Text);
        cmd.ExecuteNonQuery();

        Under certain circumstance i wont want to update the @password field. Is this possible, if so how? Or do i need to use a seperate stored procedure which doesnt mention the field(s) which shouldn't be updated? Thanks.

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        Hey... you are not running a query. Just check the value of password, send DbNull.Value from here and check in the stored Proc :

        If @password IS NULL
        BEGIN
        -- Update only the UserName
        END
        ELSE
        BEGIN
        -- UPDATE both username and password.
        END

        :rose::rose:

        Abhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
        Create .NET Templates

        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