如何使用 Jet.OLEDB.4.0 提供程序连接两个字符串

发布于 2024-07-21 03:40:06 字数 760 浏览 2 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉酒的小男人 2024-07-28 03:40:06

您必须使用 & 而不是 +

& 执行字符串连接,+ 执行(数字)加法。 使用 & 自动将所有操作数转换为字符串。

select 
 PurchaseOrderNo, 
 PurchaseOrderDate, 
 Description, 
 Quantity,
 PurchaseOrderNo & 'delimiter' & ContractNo as LinePrimaryKeys
from [POImport baseline.csv]

You have to use & instead of +.

& does a string concatenation, + performs a (numeric) addition. Using & automatically casts all operands to strings.

select 
 PurchaseOrderNo, 
 PurchaseOrderDate, 
 Description, 
 Quantity,
 PurchaseOrderNo & 'delimiter' & ContractNo as LinePrimaryKeys
from [POImport baseline.csv]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文