0

I have a mysqlcommand and mysqlparameter array []

  MySqlParameter[] param = new MySqlParameter[]{
      // params here
    };

Now I want to set the command parameter for this array. How I can do that? I got the error:

MySql.Data.MySqlClient.MySqlException:

Only MySqlParameter objects may be stored

Dharman
  • 30,962
  • 25
  • 85
  • 135
anirudha
  • 1
  • 1

1 Answers1

0

You cannot assign a parameters array directly to the SqlCommand.Parameters property, you need to use the AddRange method or add parameters one by one

mysqlcommand.Parameters.AddRange(param);

OR

for (int count = 0; count < param.Length; count++)
{
    mysqlcommand.Parameters.Add(param[count]);
}
Vladislav Zorov
  • 2,998
  • 19
  • 32
Waqas Raja
  • 10,802
  • 4
  • 33
  • 38