1

I am getting this exception from a MySqlCommand.ExecuteNonQuery():

Index and length must refer to a location within the string.

Parameter name: length

The command text is as follows:

INSERT INTO accounts
    (username, password, salt, pin, banned,
    staff, logged_in, points_a, points_b, points_c, birthday)
VALUES
    ('adminb', 'aea785fbcac7f870769d30226ad55b1aab850fb0979ee00481a87bc846744a646a649d30bca5474b59e4292095c74fa47ae6b9b3a856beef332ff873474cc0d3',
    'cb162ef55ff7c58c7cb9f2a580928679', '', '0, '0', '0', '0',
    '0', '0', '2010-04-18')

Sorry for the long string, it is a SHA512 hash. I tried manually adding this data in the table from MySQL GUI tools, and it worked perfectly. I see no "out of range" problem in these strings. Does anybody see something wrong?

1
  • I can't help with the index out of range, other then the obvious missing '. But you should definitely be using a parameterised query. Put the values into parameters on the command object instead of straight into a string. It will help avoid all sorts of issues, like SQL Injection... Commented Apr 18, 2010 at 22:07

1 Answer 1

1

I can't explain the error message, but I can see one thing that is wrong:

'0,

There is a single quote missing. It should be this:

'0',
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.