Here is the code:
OpenMC400();
iDB2Command cmd = new iDB2Command();
cmd.Connection = cn;
cmd.CommandText = @"call UPMITGCUS.RETRIEVE_MEMBER_SUMMARY(@insubno, @inperno, @ingroup, @insubgroup, @inplancode, @indate, @ques)";
cmd.CommandType = System.Data.CommandType.Text;
cmd.DeriveParameters();
//Set the parameter values
cmd.Parameters["@insubno"].Value = memberNbr;
cmd.Parameters["@inperno"].Value = person;
cmd.Parameters["@ingroup"].Value = group;
cmd.Parameters["@insubgroup"].Value = subGroup;
cmd.Parameters["@inplancode"].Value = plancode;
cmd.Parameters["@indate"].Value = date;
iDB2DataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Console.WriteLine(dr.GetiDB2Char(0).Value.ToString()
+ " " + dr.GetiDB2Char(1).Value.ToString()
+ " " + dr.GetiDB2Char(2).Value.ToString()
+ " " + dr.GetiDB2Char(3).Value.ToString()
+ " " + dr.GetiDB2Char(4).Value.ToString()
+ " " + DateTime.Parse(dr.GetiDB2Date(6).ToNativeFormat())
);
}
Here is the error:
{"String was not recognized as a valid DateTime."}
When converting a string to DateTime, parse the string to take the date before putting each variable into the DateTime object.
I have tried different things and it still gives me the error. The other variables come out fine when date is commented out.
Thanks for any help.
arep
Loading
Guest UserPosted Aug 16, 2011, 2:19 PM
A RepaskyPosted Aug 18, 2011, 11:03 AM
Thanks,
arep
Guest UserPosted Aug 16, 2011, 5:32 PM
DateTime.ParseExact(dr.GetiDB2Char(6).Value.ToString(), "yyyyMMdd", CultureInfo.InvariantCulture)
A RepaskyPosted Aug 16, 2011, 3:43 PM
20100101
Guest UserPosted Aug 16, 2011, 2:57 PM
A RepaskyPosted Aug 16, 2011, 2:47 PM
A RepaskyPosted Aug 16, 2011, 2:30 PM
The error is:
{"String was not recognized as a valid DateTime."}
When converting a string to DateTime, parse the string to take the date before putting each variable into the DateTime object.