//选取随笔发表日期
public int[] LoadDayArray(int BlogID,int intYear,int intMonth)
{
int[] intArray = new int[31];
Connection.Open();
string sql = "select [time] as [intDate] from Essay where year([time]) = " + intYear + " and month([time]) = " + intMonth + " and BlogID = " + BlogID;
OleDbCommand sqlComm = new OleDbCommand(sql,Connection);
OleDbDataReader tmpReader = sqlComm.ExecuteReader();
int i = 0;
while(tmpReader.Read())
{
if( i==0 )
{
intArray[i] = tmpReader.GetDateTime(0).Day;
i++;
}
else if( tmpReader.GetDateTime(0).Day != intArray[i-1] )
{
intArray[i] = tmpReader.GetDateTime(0).Day;
i++;
}
}
Connection.Close();
return intArray;
}异常详细信息: System.InvalidCastException: 由于符号不匹配或数据溢出以外的其他原因,未能转换数据值。例如,数据在数据存储区中已损坏,但该行仍可以检索。源错误:
行 244: if( i==0 )
行 245: {
行 246: intArray[i] = tmpReader.GetDateTime(0).Day;
行 247: i++;
行 248: }
在246行出错.
我用的是ACCESS数据库,用MSSQL Server2000是没有错的,换成ACCESS数据库就出错了,哪位高手知道是怎么回事吗?谢谢!!
public int[] LoadDayArray(int BlogID,int intYear,int intMonth)
{
int[] intArray = new int[31];
Connection.Open();
string sql = "select [time] as [intDate] from Essay where year([time]) = " + intYear + " and month([time]) = " + intMonth + " and BlogID = " + BlogID;
OleDbCommand sqlComm = new OleDbCommand(sql,Connection);
OleDbDataReader tmpReader = sqlComm.ExecuteReader();
int i = 0;
while(tmpReader.Read())
{
if( i==0 )
{
intArray[i] = tmpReader.GetDateTime(0).Day;
i++;
}
else if( tmpReader.GetDateTime(0).Day != intArray[i-1] )
{
intArray[i] = tmpReader.GetDateTime(0).Day;
i++;
}
}
Connection.Close();
return intArray;
}异常详细信息: System.InvalidCastException: 由于符号不匹配或数据溢出以外的其他原因,未能转换数据值。例如,数据在数据存储区中已损坏,但该行仍可以检索。源错误:
行 244: if( i==0 )
行 245: {
行 246: intArray[i] = tmpReader.GetDateTime(0).Day;
行 247: i++;
行 248: }
在246行出错.
我用的是ACCESS数据库,用MSSQL Server2000是没有错的,换成ACCESS数据库就出错了,哪位高手知道是怎么回事吗?谢谢!!
try
{
intArray[i] = tmpReader.GetDateTime(0).Day;
}
catch(Exception ex)
{
MessageBox.Show(ex);
}
查查看提示什么信息.