This error indicates that the value "datatbl5.Rows[0][0]" is null or is not a string that contains the number to convert.
For example, you can't convert the "abc" to int by using the
Convert.ToInt32 method.
You can use
Int32.TryParse method, and it returns a value that indicates whether the operation succeeded.
Here is a simple code example.
int Credits;
bool s = Int32.TryParse(table.Rows[0][0].ToString(), out Credits);
Best Regards,
Daniel Zhang
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.