Fix error "Index (zero based) must be greater than or equal to zero and less than the size of the argument list"




Not so long ago when I was very tired I wrote an SQL-query in my C# application in Visual Studio, but I got error on build. The error was " Index (zero based) must be greater than or equal to zero and less than the size of the argument list.". Error string was this:

updateCommand = String.Format("UPDATE [UserTbl] SET [PhoneWork] = '{0}', 
             [PhoneHome] = '{1}', 
             [PhoneMob] = '{2}', 
WHERE [EntityId] = '{3}'", PhoneWork, PhoneHome, PhoneMob);

 

If I wasn’t tired I couldn’t even write so, but here I have just forgotten to write {3} value.

$updateCommand = string.format("UPDATE [UserTbl] SET [PhoneWork] = '{0}',
[PhoneHome] = '{1}',
[PhoneMob] = '{2}',
WHERE [EntityId] = '{3}'", PhoneWork, PhoneHome, PhoneMob, EntityId);

 

So this post is for all tired developers.




No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment





MarkiMarta.com. Notes of web-specialist
Since 2009
18+