Hi all,
I am trying to insert data from C# to mysql database using stored procedures. During execution, I am getting this error:
Unable to cast object of type 'System.Int32[]' to type 'System.IConvertible'
The code I am trying to run is as follows:
int cpoints = 2;
int[] cpointsarray = { cpoints };
MySqlParameter cpointsparam = new MySqlParameter("p_points", MySqlDbType.Int32);
cpointsparam.Direction = System.Data.ParameterDirection.Input;
cpointsparam.Value = cpointsarray;
cmd.Parameters.Add(cpointsparam);
Do I need to specify Int32 somewhere.. ?
Many thanks in advance,
Regards,
Abhi

1 answers
Hi Guys,
I changed everything to varchar and string. It's working now. Data is going through the stored procedure and being inserted into database.
But now, there is another problem.
The value being inserted is
System.String[]
What could possibly be the reason?
Regards,
Abhi
answered 2 years ago by:
201
Hi,
Finally figured out the solution.
The part of the code,
int[] cpointsarray = { cpoints };
and similarly, the other variable name, i.e. `string[] cnamearray = { cname }; was not necessary and was creating the problem.
I removed them, and used cpoints and cname directly as input values.
Many thanks,
Abhi
answered 2 years ago by:
201
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!