0

I am getting this error:

String was not recognized as a valid Boolean.Couldn't store <No> in meetsstd Column.  Expected type is Boolean

When I am running this query:

SELECT * FROM work_nylustis_2013_q3.nylustis_details WHERE siteid = 'NYLUSTIS-155718'  LIMIT 50

From this code:

Adapter.SelectCommand = New NpgsqlCommand(SQL, MLConnect)
Adapter.Fill(subDT)   ' This line throws error

The meetsstd field is a varchar(3) and it does store either a 'Yes' or a 'No' value. How is this getting this confused with a boolean - a varchar should not care whether is holds 'Yes', or 'Si', or 'Oui'? And it only happens on 27 records out of the 28,000 in the table.

I usually blame npgsql for this kind of strangeness, but the last entry in the stack trace is: System.Data.DataColumn.set_Item(Int32 record, Object value)

Any clues?

Thanks! Brad

4

1 回答 1

1

要检查数据库或驱动程序是否有问题,您可以使用当前环境将问题减少到一行和一列:

SELECT meetsstd FROM work_nylustis_2013_q3.nylustis_details WHERE sitenum=1

(当然你必须sitenum改成主键)

然后尝试使用 或一些基于 JDBC/ODBC 的通用编辑器进行此类psql查询pgAdmin

如果psql显示这样的记录会在基于 Npgsql 的应用程序中引发错误,则问题出在 Npgsql 驱动程序或问题出在显示查询结果上。

如果其他工具显示此类奇怪的错误,那么问题出在您的数据上。

您是否更改了meetsstd字段类型?Mayby 您尝试在某个网格上显示它,并且该网格使用了转换为Yes/No用于显示的布尔字段?

于 2013-09-10T12:40:12.387 回答