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. Stored procedure

Stored procedure

Scheduled Pinned Locked Moved ASP.NET
databasedesignhelp
6 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
    mylogics
    wrote on last edited by
    #1

    hi i have created stored procedure as follows:

    ALTER PROCEDURE dbo.StoredProcedure1
    (
    @ID varchar(50),
    @PassWord varchar(50),
    @confirmPassword varchar(50),
    @EmailID varchar(50)
    )
    AS
    /* SET NOCOUNT ON */
    insert into Login(ID,Password,ConfirmPassword,EmailID)Values(@ID,@PassWord,@ConfirmPassWord,@EmailID)
    RETURN

    then i have used this storedprocedure in coding as.Actually m tryin to submit a form containing id,password,conformpassword,email in table named Login:the code is:

    public partial class emplogin : System.Web.UI.Page
    {
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Jajaipur"].ConnectionString);
    SqlCommand cmd=new SqlCommand();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1\_Click(object sender, EventArgs e)
    {
        SqlParameter ID = new SqlParameter();
        SqlParameter Password = new SqlParameter();
        SqlParameter Confirm = new SqlParameter();
        SqlParameter Email = new SqlParameter();
        cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value=txtid.Text;
        cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value=txtpassword.Text;
        cmd.Parameters.Add("@Confirm", SqlDbType.VarChar).Value=txtconfirmpassword.Text;
        cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value=txtemailid.Text;
        cmd = new SqlCommand("StoredProcedure1",conn);
        cmd.CommandType = CommandType.StoredProcedure;
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
        txtid.Text="";
        txtpassword.Text="";
        txtemailid.Text="";
        txtconfirmpassword.Text="";
    }
    

    }

    i got this error on rub time:Procedure or function 'StoredProcedure1' expects parameter '@ID', which was not supplied. plz tell me wr m i wrong....

    G 1 Reply Last reply
    0
    • M mylogics

      hi i have created stored procedure as follows:

      ALTER PROCEDURE dbo.StoredProcedure1
      (
      @ID varchar(50),
      @PassWord varchar(50),
      @confirmPassword varchar(50),
      @EmailID varchar(50)
      )
      AS
      /* SET NOCOUNT ON */
      insert into Login(ID,Password,ConfirmPassword,EmailID)Values(@ID,@PassWord,@ConfirmPassWord,@EmailID)
      RETURN

      then i have used this storedprocedure in coding as.Actually m tryin to submit a form containing id,password,conformpassword,email in table named Login:the code is:

      public partial class emplogin : System.Web.UI.Page
      {
      SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Jajaipur"].ConnectionString);
      SqlCommand cmd=new SqlCommand();
      protected void Page_Load(object sender, EventArgs e)
      {

      }
      protected void Button1\_Click(object sender, EventArgs e)
      {
          SqlParameter ID = new SqlParameter();
          SqlParameter Password = new SqlParameter();
          SqlParameter Confirm = new SqlParameter();
          SqlParameter Email = new SqlParameter();
          cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value=txtid.Text;
          cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value=txtpassword.Text;
          cmd.Parameters.Add("@Confirm", SqlDbType.VarChar).Value=txtconfirmpassword.Text;
          cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value=txtemailid.Text;
          cmd = new SqlCommand("StoredProcedure1",conn);
          cmd.CommandType = CommandType.StoredProcedure;
          conn.Open();
          cmd.ExecuteNonQuery();
          conn.Close();
          txtid.Text="";
          txtpassword.Text="";
          txtemailid.Text="";
          txtconfirmpassword.Text="";
      }
      

      }

      i got this error on rub time:Procedure or function 'StoredProcedure1' expects parameter '@ID', which was not supplied. plz tell me wr m i wrong....

      G Offline
      G Offline
      Greg Chelstowski
      wrote on last edited by
      #2

      Ok. Short version: move this line:

                  cmd = new SqlCommand("StoredProcedure1",conn);
      

      to the top of your method. Longer version: read up on collections. [edit]sorry, wrong line[/edit]

      mylogics wrote:

      i got this error on RUB time

      I know it was a typo, but soooo funny ;)

      var question = (_2b || !(_2b));

      M 1 Reply Last reply
      0
      • G Greg Chelstowski

        Ok. Short version: move this line:

                    cmd = new SqlCommand("StoredProcedure1",conn);
        

        to the top of your method. Longer version: read up on collections. [edit]sorry, wrong line[/edit]

        mylogics wrote:

        i got this error on RUB time

        I know it was a typo, but soooo funny ;)

        var question = (_2b || !(_2b));

        M Offline
        M Offline
        mylogics
        wrote on last edited by
        #3

        i tried but givin same error...

        G E 2 Replies Last reply
        0
        • M mylogics

          i tried but givin same error...

          G Offline
          G Offline
          Greg Chelstowski
          wrote on last edited by
          #4

          Look man, it wont give an error, alright? Please read my edited post. You were adding to a collection of an object and then you constructed it again, therefore losing all previously assigned properties. Move that line to before you're starting to add parameters and all will be well. Believe me.

          var question = (_2b || !(_2b));

          M 1 Reply Last reply
          0
          • M mylogics

            i tried but givin same error...

            E Offline
            E Offline
            Elayaraja Sambasivam
            wrote on last edited by
            #5

            change the code as blow.... protected void Button1_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("StoredProcedure1",conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value=txtid.Text; cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value=txtpassword.Text; cmd.Parameters.Add("@Confirm", SqlDbType.VarChar).Value=txtconfirmpassword.Text; cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value=txtemailid.Text; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); txtid.Text=""; txtpassword.Text=""; txtemailid.Text=""; txtconfirmpassword.Text=""; }

            1 Reply Last reply
            0
            • G Greg Chelstowski

              Look man, it wont give an error, alright? Please read my edited post. You were adding to a collection of an object and then you constructed it again, therefore losing all previously assigned properties. Move that line to before you're starting to add parameters and all will be well. Believe me.

              var question = (_2b || !(_2b));

              M Offline
              M Offline
              mylogics
              wrote on last edited by
              #6

              thnks it worked... :laugh:

              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