I have a register page that saves the data to a database the only problem is when I click the register button I am getting an error which im not too sure how to solve, please see below.
1 Answer
Your declaring param[] to have 6 elements, but you're only using 5. The last one is null so you're getting the error on the last iteration of your for loop where you add the elements to the SqlParameterCollection.
It would be much cleaner/easier to do the following rather than declaring an array, filling the array, and then trying to copy the array:
cmd.Parameters.AddWithValue("@Name", name);
cmd.Parameters.AddWithValue("@Gender", gender);
cmd.Parameters.AddWithValue("@Age", age);
cmd.Parameters.AddWithValue("@Address", address);
cmd.Parameters.AddWithValue("@Email", email);
1 Comment
user1300580
works fine that thanks but now come across another error - Insert Error:Cannot open database "SJDatabase" requested by the login. The login failed. Login failed for user