Simplest solution is to return the value, instead of using a "global variable":
private static Random objran = new Random();
private static string Generate_OTP()
{
string strRandom = "";
string chars = "0123456789";
int No_of_Characters = 6;
for (int i = 0; i < No_of_Characters; i++)
{
int pos = objran.Next(1, chars.Length);
string newChar = chars[pos].ToString();
strRandom += newChar;
chars = chars.Replace(newChar, "");
}
return strRandom;
}
You then just use it like this:
SQL.Parameters.AddWithValue("TEXT_ME_RESET_PASSWORD", Generate_OTP());