I am getting this exception Input string was not in a correct format
while executing the mysql stored procedure in C#.
Below is my sample code:
MySqlManager dac = new MySqlManager();
DbCommand dbCommand = dac.GetStoredProcCommand("DocdetailsById");
dac.AddInParameter(dbCommand, "p_P_ID", DbType.Int32, id);
dac.AddInParameter(dbCommand, "p_P_Mode", DbType.Int32, mode);
dac.AddInParameter(dbCommand, "p_P_IPADDRESS", DbType.String, ipaddress);
dac.AddInParameter(dbCommand, "p_P_OsBrowser", DbType.String, SessionManager.OSandBrowser);
dac.AddInParameter(dbCommand, "p_P_Subscriberid", DbType.Int32, SessionManager.SubscriberId);
IDataReader reader = dac.ExecuteReader(dbCommand);
List<FilesDTO> result = new List<FilesDTO>();
while (reader.Read())
{
result.Add(new FilesDTO
{
EmailID = reader["EmailID"] == DBNull.Value ? default(string) : Convert.ToString(reader["EmailID"]),
DocumentID = reader["DocumentID"] == DBNull.Value ? default(int) : Convert.ToInt32(reader["DocumentID"]),
Name = reader["Name"] == DBNull.Value ? default(string) : Convert.ToString(reader["Name"]),
DocumentName = reader["DocumentName"] == DBNull.Value ? default(string) : Convert.ToString(reader["DocumentName"]),
StatusID = reader["StatusID"] == DBNull.Value ? default(int) : Convert.ToInt32(reader["StatusID"]),
SubscriberID = reader["SubscriberID"] == DBNull.Value ? default(int) : Convert.ToInt32(reader["SubscriberID"]),
CreatedBy = reader["Initiater"] == DBNull.Value ? default(int) : Convert.ToInt32(reader["Initiater"]),
DelegatorName = reader["DelegatorName"] == DBNull.Value ? default(string) : Convert.ToString(reader["DelegatorName"]),
DelegatorEmailID = reader["DelegatorEmailID"] == DBNull.Value ? default(string) : Convert.ToString(reader["DelegatorEmailID"]),
SignatureType = reader["SignatureType"] == DBNull.Value ? default(Int16) : Convert.ToInt16(reader["SignatureType"])
});
}
dac.CloseConnection(dbCommand, reader);
return result;
Once the ExecuteReader execution is done, i am getting the exception in reader.Read() as System.formatexception in DocumentID = reader["DocumentID"] == DBNull.Value ? default(int) : Convert.ToInt32(reader["DocumentID"]),
Please Can anyone help me? Thanks.