如何使用 Jet.OLEDB.4.0 提供程序连接两个字符串
我将查询传递给运行该查询并返回结果的内部应用程序,连接到 CSV 文件,并且我正在与 Provider=Microsoft.Jet.OLEDB.4.0 连接,
我想加入字符串到一列,但我收到错误。
这个可以做吗,有人知道怎么做吗?
我正在做的示例:
select
PurchaseOrderNo,
PurchaseOrderDate,
Description,
Quantity,
ContractName + 'delimiter' + ContractNo as LinePrimaryKeys
from [POImport baseline.csv]
错误是: - 错误 - 提供程序无法确定 Double 值。 例如,该行刚刚创建,Double 列的默认值不可用,并且使用者尚未设置新的 Double 值。
从其他阅读来看,我加入的两个值似乎都没有被识别为字符串。
例如更换 PurchaseOrderNo + '分隔符' + ContractNo 作为 LinePrimaryKeys 和 PurchaseOrderNo + '分隔符' + PurchaseOrderNo 作为 LinePrimaryKeys
停止错误。 那么现在我该如何投射到字符串呢?
这是行不通的。 ContractName + 'cn' + CAST(ContractName as nvarchar(50)) as LinePrimaryKeys
I'm passing a query to an internal application that runs that query and returns the result, the connection is to a CSV file and I'm connecting with the Provider=Microsoft.Jet.OLEDB.4.0
I'd like to join to strings in to one column but I'm getting an error.
Can this be done, does anyone know how to do it?
Example of what I'm doing:
select
PurchaseOrderNo,
PurchaseOrderDate,
Description,
Quantity,
ContractName + 'delimiter' + ContractNo as LinePrimaryKeys
from [POImport baseline.csv]
the error is:
- Error - The provider could not determine the Double value. For example, the row was just created, the default for the Double column was not available, and the consumer had not yet set a new Double value.
From other reading it looks like not both of the values I'm joining are being recognized as strings.
for example replacing
PurchaseOrderNo + 'delimiter' + ContractNo as LinePrimaryKeys
with
PurchaseOrderNo + 'delimiter' + PurchaseOrderNo as LinePrimaryKeys
stops the error. So now how do I Cast to string?
This doesn't work.
ContractName + 'cn' + CAST(ContractName as nvarchar(50)) as LinePrimaryKeys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用 & 而不是 +。
& 执行字符串连接,+ 执行(数字)加法。 使用 & 自动将所有操作数转换为字符串。
You have to use & instead of +.
& does a string concatenation, + performs a (numeric) addition. Using & automatically casts all operands to strings.