我在Visual Studio 2010中多次生成DataSets时使用了ODBC驱动程序,但是这次都出错了. DB中的表具有一组定义为numeric(7,2)的列.我尝试通过自动生成的Insert方法插入数据,如下所示:
I''ve used the ODBC driver when generating DataSets in Visual Studio 2010 multiple times, but this time it all went wrong. The table in the DB has a set of columns defined as numeric(7,2). I try to insert data through the autogenerated Insert method like this:
int x = tableAdapterMyDataTable.Insert( (decimal)data.X, (decimal)data.Y, (decimal)data.Z);在运行时,我收到一条错误消息:
In run-time I get an error saying:
ERROR [22P02] ERROR: invalid input syntax for type numeric: "-1,6"; Error while executing the query显然,小数点分隔符是,"(逗号)是一个问题.由于TableAdapter中没有CultureInfo,因此我很难更改它.一个无用的解决方法是更改Windows中的小数点符号.可以,但是不能使用. 设置应用程序的区域性也不起作用:
Clearly it is a problem with the decimal separator being '','' (comma). Since there are no CultureInfo in the TableAdapter, I have trouble changing it. A useless workaround is to change the decimal symbol in Windows. That works, but can''t be used. Setting the culture of the application doesn''t work either:
Application.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfoByIetfLanguageTag("en-US");有什么建议吗? ODBC驱动程序8.04 PostgreSQL 8.4
Any suggestions? ODBC Driver 8.04 PostgreSQL 8.4
推荐答案大声笑,事情以神秘的方式起作用! 事实证明,要使Postgres ODBC驱动程序正常工作,我必须在将数据插入表之前从表中读取.在所有其他应用程序中,我都从数据库读取和写入.在我当前的应用程序中,我只写东西,这就是区别. 所以在我写之前,我必须先阅读以下内容: Lol, things work in mysterious ways! It turns out that to get the Postgres ODBC driver to work properly I had to read from the table before inserting data into it. In all other applications I did read from the DB as well as write. In my current application I only write, and that was the difference. So before I write, I have to do a little reading: someDataSetTableAdapters.amunds_dataTableAdapter taData = new someDataSetTableAdapters.amunds_dataTableAdapter(); someDataSet sds = new someDataSet(); someDataSet.amunds_dataDataTable adt = sds.amunds_data; taData.Fill1(adt); // SELECT * FROM amunds_data LIMIT 1 int x = taWeatherData.Insert( (decimal)data.X, (decimal)data.Y, (decimal)data.Z);
伙计,我已经用谷歌搜索了!希望将来对某人有帮助.
Man, I''ve googled this one! Hope it will help somebody sometime in the future.
更多推荐
更改Postgresql ODBC驱动程序上的区域性
发布评论