更改Postgresql ODBC驱动程序上的区域性

编程入门 行业动态 更新时间:2024-10-12 01:30:57
本文介绍了更改Postgresql ODBC驱动程序上的区域性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在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驱动程序上的区域性

本文发布于:2023-11-12 12:55:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581551.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区域性   驱动程序   Postgresql   ODBC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!