使用C#向Paradox表插入查询的问题 [英] Problem with Insert query to Paradox table using C#

查看:164
本文介绍了使用C#向Paradox表插入查询的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要连接到Paradox 5.x表才能进行选择和更新. 我正在使用OLEDBConnection.

I have Paradox 5.x tables i need to connect to in order to select and update. I am using OLEDBConnection.

从表中选择我没有问题. 在尝试插入表时,我输入硬编码的字段namesi时遇到错误: INSERT INTO语句包含以下未知字段名称:... 所以我用OleDbDataReader.GetName(...)来获取字段名称. 现在,我使用从表中获取的字段名称来插入表中,但仍然遇到相同的错误.

selecting from the tables i have no problem. while trying to insert into the tables i met a problem when i entered hardcoded the fields namesi got an error: The INSERT INTO statement contains the following unknown field name: ... so i used OleDbDataReader.GetName(...) to get fields names. now i use the fields names recived from table in order to insert into table and i still get the same error.

我认为问题出在字段名称:卡车#1序列号" 表格名称:车辆"

I think the problem is with the field name: 'Truck #1 Serial Number' Table name: 'Vehicles'

我尝试使用[] 、.",.[]和 .["].

I tried using [], ."", .[] and .[""].

我已经了解了Borland引擎的需求,但是我不确定这是问题所在. 谢谢你.

I have read about the need of Borland engine but im not sure this is the issue. Thanks upfront.

-= Noam =-

-=Noam=-

p.s我无法更改表的名称,因为它需要连接一个Castumer DB.

p.s I cannot change name of tables since its a castumer DB i need to connect.

我正在添加我使用的C#代码:

Im adding the C# code i use:

private static string createInsertQueryVehicle(string i_VehicleNumber, string i_VehicleMFG, string i_Truck1SerialNo, string i_Truck2SerialNo, string i_Truck3SerialNo)
        {
            string tryout = string.Format("INSERT INTO {0} ([{6}], [{7}], [{8}], [{9}], [{10}]) VALUES(RIGHT('{1}',10),'{2}','{3}','{4}','{5}')",
                TableName, Vnum, Vinfo, T1Serial, T2Serial, T3Serial, VnumFieldName, VinfoFieldName, T1SerialFieldName
                T2SerialFieldName,T3SerialFieldName);
            return tryout;
        }

最终试用版保存:

INSERT INTO Vehicles ([Vehicle Number], [Vehicle Mfg], [Truck #1 Serial Number], [Truck #2 Serial Number], [Truck #3 Serial Number]) VALUES(RIGHT('000000010001525',10),'קרונות משא','ר40011_1','ר40011_2','')

只是想在末尾添加我的解决方案: 最后,我能获得的最佳解决方案是使用访问权作为连接点,使用指向表的链接表,最后将其作为acceses DB处理. 希望它能对某人有所帮助.

Just wanted to add my solution at end: At the end the best solution i could get was to use accesses as the connection point using linked tablse to the paradox tables, at end handling it as an acceses DB..... Hope it helps someone.

推荐答案

我能够通过创建带有带有数字符号(col#)的列的表(Table1)来重现该问题.喜欢:

I was able to reproduce the problem by creating a table (Table1) with a column that has number sign (col#). Like:

INSERT INTO `Table1.db` (`col#`) VALUES ('a')

在运行此SQL的地方出现此错误:

Where I run this SQL I get this Error:

The INSERT INTO statement contains the following unknown field name: 'col#'.  Make sure you have typed the name correctly, and try the operation again.

这似乎是Microsoft JET提供程序的错误.找到的唯一解决方法是将值插入到另一列,例如

This seems to be a bug Microsoft JET provider. The only workaround is found is to insert the value into another column like

INSERT INTO `Table1.db` (`col1`) VALUES ('a')

然后更新col#列:

UPDATE `Table1.db` SET `col#` = col1

我发现JET提供程序还有其他问题.例如,如果表没有主键或密码保护,则会出现此错误错误:

I found other problems with the JET provider. For example, you will get this wrong error if the table is does not have a primary key or password protected:

Operation must use an updateable query.

这篇关于使用C#向Paradox表插入查询的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆