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. Parameter 'xxxxx' not found in the collection

Parameter 'xxxxx' not found in the collection

Scheduled Pinned Locked Moved ASP.NET
helpdatabasemysqlquestion
11 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.
  • J Jassim Rahma

    Hi, I am getting the following error:

    Parameter 'param_login_ip_address' not found in the collection.

    but parameter was already submitted here:

    sql_command.Parameters.Add("param_login_ip_address", MySqlDbType.VarChar).Value = (string)Request.ServerVariables["REMOTE_ADDR"];

    and it's already specified in the MySQL parameters as well:

    IN `param_id_number` varchar(255),IN `param_login_password` varchar(255),IN `param_login_pin` varchar(255),IN `param_login_ip_address` varchar(255),IN `param_machine_name` varchar(255),IN `param_os_version` varchar(255)

    then where is the problem please?

    P Offline
    P Offline
    Parwej Ahamad
    wrote on last edited by
    #2

    REMOTE_ADDR not always return client IP address so it cause error. Go through with discussion http://stackoverflow.com/questions/735350/how-to-get-a-users-client-ip-address-in-asp-net[^] Hope so you will all constrains. Thanks

    Parwej Ahamad

    1 Reply Last reply
    0
    • J Jassim Rahma

      Hi, I am getting the following error:

      Parameter 'param_login_ip_address' not found in the collection.

      but parameter was already submitted here:

      sql_command.Parameters.Add("param_login_ip_address", MySqlDbType.VarChar).Value = (string)Request.ServerVariables["REMOTE_ADDR"];

      and it's already specified in the MySQL parameters as well:

      IN `param_id_number` varchar(255),IN `param_login_password` varchar(255),IN `param_login_pin` varchar(255),IN `param_login_ip_address` varchar(255),IN `param_machine_name` varchar(255),IN `param_os_version` varchar(255)

      then where is the problem please?

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #3

      jrahma wrote:

      (string)Request.ServerVariables["REMOTE_ADDR"];

      As the previous post said, you have to make sure the value really exist before you assign it to something. 1. So you should of gathered up all your data first, 2. check to make sure it is complete and formatted correctly, 3. then do your write to the database.

      J 1 Reply Last reply
      0
      • J jkirkerx

        jrahma wrote:

        (string)Request.ServerVariables["REMOTE_ADDR"];

        As the previous post said, you have to make sure the value really exist before you assign it to something. 1. So you should of gathered up all your data first, 2. check to make sure it is complete and formatted correctly, 3. then do your write to the database.

        J Offline
        J Offline
        Jassim Rahma
        wrote on last edited by
        #4

        I am sure REMOTE_ADDR is returning the correct value. because I tried to write it and getting the data. also I am getting everything working on local laptop and this problem occurs only on host. I even tried to pass DBNull.Value but getting the same error!

        if (Request.ServerVariables["REMOTE_ADDR"] != null) sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;
        else sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;

        J J 2 Replies Last reply
        0
        • J Jassim Rahma

          I am sure REMOTE_ADDR is returning the correct value. because I tried to write it and getting the data. also I am getting everything working on local laptop and this problem occurs only on host. I even tried to pass DBNull.Value but getting the same error!

          if (Request.ServerVariables["REMOTE_ADDR"] != null) sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;
          else sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;

          J Offline
          J Offline
          Jassim Rahma
          wrote on last edited by
          #5

          you can see the error here: http://www.rmc.bh/en/EmployeeSignin.aspx[^] just enter anything in the ID, password and PIN...

          J 1 Reply Last reply
          0
          • J Jassim Rahma

            I am sure REMOTE_ADDR is returning the correct value. because I tried to write it and getting the data. also I am getting everything working on local laptop and this problem occurs only on host. I even tried to pass DBNull.Value but getting the same error!

            if (Request.ServerVariables["REMOTE_ADDR"] != null) sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;
            else sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;

            J Offline
            J Offline
            jkirkerx
            wrote on last edited by
            #6

            I always copy the pointer to a buffer like ipAddress before using it.

            if (Request.ServerVariables["REMOTE_ADDR"] != null){
            ipAddress String = Request.ServerVariables["REMOTE_ADDR"];
            sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = ipAddress;
            }
            else
            {
            sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;
            }

            1 Reply Last reply
            0
            • J Jassim Rahma

              you can see the error here: http://www.rmc.bh/en/EmployeeSignin.aspx[^] just enter anything in the ID, password and PIN...

              J Offline
              J Offline
              jkirkerx
              wrote on last edited by
              #7

              That's a nice looking website, good job. I like the buttons, whole site is nice and clean. param_ipAddress, the param is missing from 1 of 3 places, below

              UPDATE Contact Set(ipAddress=@ipAddress) <- Is this missing

              Or is your Param not stated correctly ?

              Dim paramIPAddress As SqlParameter
              paramIPAddress = New SqlParameter("@ipAddress", SqlDbType.VarChar, 80)
              paramIPAddress.Value = ipAddress
              myCommand.Parameters.Add(paramIPAddress)

              Or is the value simply missing?

              ipAddress simply has no value and = nothing

              J 1 Reply Last reply
              0
              • J jkirkerx

                That's a nice looking website, good job. I like the buttons, whole site is nice and clean. param_ipAddress, the param is missing from 1 of 3 places, below

                UPDATE Contact Set(ipAddress=@ipAddress) <- Is this missing

                Or is your Param not stated correctly ?

                Dim paramIPAddress As SqlParameter
                paramIPAddress = New SqlParameter("@ipAddress", SqlDbType.VarChar, 80)
                paramIPAddress.Value = ipAddress
                myCommand.Parameters.Add(paramIPAddress)

                Or is the value simply missing?

                ipAddress simply has no value and = nothing

                J Offline
                J Offline
                Jassim Rahma
                wrote on last edited by
                #8

                is it really nice? :) Thanks.. I am still working on completing it :) Regarding where I am using it in the stored procedure.. it's here:

                IN `param_id_number` varchar(255),IN `param_login_password` varchar(255),IN `param_login_pin` varchar(255),IN `param_ip_address` varchar(255),IN `param_machine_name` varchar(255),IN `param_os_version` varchar(255)

                and then here:

                INSERT INTO event_log (event_log_category, event_log_user, event_log_ip_address, event_log_machine_name, event_log_os_version, event_log_text) VALUES ('Audit', param_id_number, param_ip_address, param_machine_name, param_os_version, 'User logged on successfully');

                and this is my parameter:

                if (Request.ServerVariables["REMOTE_ADDR"] != null) sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = Request.ServerVariables["REMOTE_ADDR"];
                else sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;

                value is not missing because I am able to write and I am also checking it if not null as you can see in above code...

                J J 2 Replies Last reply
                0
                • J Jassim Rahma

                  is it really nice? :) Thanks.. I am still working on completing it :) Regarding where I am using it in the stored procedure.. it's here:

                  IN `param_id_number` varchar(255),IN `param_login_password` varchar(255),IN `param_login_pin` varchar(255),IN `param_ip_address` varchar(255),IN `param_machine_name` varchar(255),IN `param_os_version` varchar(255)

                  and then here:

                  INSERT INTO event_log (event_log_category, event_log_user, event_log_ip_address, event_log_machine_name, event_log_os_version, event_log_text) VALUES ('Audit', param_id_number, param_ip_address, param_machine_name, param_os_version, 'User logged on successfully');

                  and this is my parameter:

                  if (Request.ServerVariables["REMOTE_ADDR"] != null) sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = Request.ServerVariables["REMOTE_ADDR"];
                  else sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;

                  value is not missing because I am able to write and I am also checking it if not null as you can see in above code...

                  J Offline
                  J Offline
                  Jassim Rahma
                  wrote on last edited by
                  #9

                  Thanks everyone. My problem if solved. I used:

                  if (Request.ServerVariables["REMOTE_ADDR"] != null) sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = HttpContext.Current.Request.UserHostAddress;
                  else sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;

                  J 1 Reply Last reply
                  0
                  • J Jassim Rahma

                    Thanks everyone. My problem if solved. I used:

                    if (Request.ServerVariables["REMOTE_ADDR"] != null) sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = HttpContext.Current.Request.UserHostAddress;
                    else sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;

                    J Offline
                    J Offline
                    Jassim Rahma
                    wrote on last edited by
                    #10

                    sorry... problem is still there.. :( I didn't notice I was working on local... and that's another question.. why it's working on local but throwing the error on host?!

                    1 Reply Last reply
                    0
                    • J Jassim Rahma

                      is it really nice? :) Thanks.. I am still working on completing it :) Regarding where I am using it in the stored procedure.. it's here:

                      IN `param_id_number` varchar(255),IN `param_login_password` varchar(255),IN `param_login_pin` varchar(255),IN `param_ip_address` varchar(255),IN `param_machine_name` varchar(255),IN `param_os_version` varchar(255)

                      and then here:

                      INSERT INTO event_log (event_log_category, event_log_user, event_log_ip_address, event_log_machine_name, event_log_os_version, event_log_text) VALUES ('Audit', param_id_number, param_ip_address, param_machine_name, param_os_version, 'User logged on successfully');

                      and this is my parameter:

                      if (Request.ServerVariables["REMOTE_ADDR"] != null) sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = Request.ServerVariables["REMOTE_ADDR"];
                      else sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;

                      value is not missing because I am able to write and I am also checking it if not null as you can see in above code...

                      J Offline
                      J Offline
                      jkirkerx
                      wrote on last edited by
                      #11

                      You don't need to check the value here, since your passing the value to a function, just make sure the value is good before passing it the fucntion, so remove the first line and do it earlier, when your gather data

                      if (Request.ServerVariables["REMOTE_ADDR"] != null) sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = Request.ServerVariables["REMOTE_ADDR"];
                      else sql_command.Parameters.Add("param_ip_address", MySqlDbType.VarChar).Value = DBNull.Value;

                      I;m not sure what the problem is. I see lot's of tiny errors like the @ in front of the parameter name. @param_id_number

                      INSERT INTO event_log (event_log_category, event_log_user, event_log_ip_address, event_log_machine_name, event_log_os_version, event_log_text) VALUES ('Audit', @param_id_number, @param_ip_address, @param_machine_name, @param_os_version, 'User logged on successfully');

                      Those examples I gave you, you really need to look at the details of them. On the param, you have to declare the variable, then make a new one. If you made the table column a width of let's say 80, use the 80. I did some digging, and I stopped using the Server Request because it was not reliable, and changed to the UserHostAddress, use the context whenever you use request or response as a good habit.

                      Dim ipAddress as String = Nothing
                      ipAddress = HttpContext.Current.Request.UserHostAddress

                      Dim param_id_number As SqlParameter
                      param_id_number = New SqlParamter("@ip_Address, SQLDbType.VarChar, 80)
                      param_id_number.Value = <- Assign a pointer here like ipAddress
                      sql_command.Parameters.Add(param_ip_address)

                      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