Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stackoverflow exception

public static int ExecuteNonQuery(String procedure, params SqlParameter[] args)
{
    if (args == null) throw new ArgumentNullException("args");
    else
    return ExecuteNonQuery(procedure, new SqlParameter[] { });
}

Why getting recursive function and throwing StackOverFlow Exception when calling this above method.(while the argument contains 5 values)

like image 574
Surya Avatar asked May 16 '26 14:05

Surya


1 Answers

Don't confuse an empty array with a null array. You're calling the same method again with an empty array, but the only check you have to cease this function is to check for a null array, and throw an exception. You need something like:

if (args.length == 0) {
   // bail out somehow
}

(after your null check, to prevent NPEs)

like image 138
Brian Agnew Avatar answered May 18 '26 03:05

Brian Agnew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!