Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
JustDave
Starting Member
2 Posts |
Posted - 2004-12-01 : 14:40:59
|
I am getting the following exception: quote: An unhandled exception of type 'System.InvalidCastException' occurred in system.data.dllAdditional information: Specified cast is not valid.
I am getting this error using: theRange.Value = rdrReportData.GetSqlInt16(x) to retrieve an integer value From the SQL Statement:Select Count(PatientNumber) From PatientBilling theRange is an excel cell, and rdrReportData is a SQLClient.SQLDataReaderI have also tried GetSQLInt32,GetSQLInt64 (which works for data type bigint), GetInt16, GetInt32, GetInt64, GetSingle, GetSQLSingle, GetDouble, GetSQLDouble, and GetValue. This happens for me with any Int value returned, wheter a field of type int or an expression with an int result.Any clues where to go/What to do would be appreciated.Thank you! JustDave |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2004-12-01 : 14:53:45
|
| Maybe try:theRange.Value = rdrReportData.GetSqlInt16(x).Valuewhat is the type of theRange.Value ?rdrReportData.GetSqlInt16(x).Value -- this is int (Int32)rdrReportData.GetSqlInt16(x) -- this is SqlInt32rockmoose |
 |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2004-12-01 : 15:09:53
|
| Perhaps the value you are trying to convert is null?Try checking the value with Convert.DbNULL or use the method Convert.IsDbNullDustin Michaels |
 |
|
|
|
|
|