Parameter 'xxxxx' not found in the collection
-
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?
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
-
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?
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.
-
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.
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; -
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;you can see the error here: http://www.rmc.bh/en/EmployeeSignin.aspx[^] just enter anything in the ID, password and PIN...
-
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;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;
} -
you can see the error here: http://www.rmc.bh/en/EmployeeSignin.aspx[^] just enter anything in the ID, password and PIN...
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
-
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
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...
-
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...
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; -
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;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?!
-
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...
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.UserHostAddressDim 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)