MS Access - 将 varchar 列与 int 列组合 - ASP.net VB.net
MS Access - Combine varchar column with int column - ASP.net VB.net
我正在使用 oledb 连接字符串将我的 asp.net 代码连接到访问数据库
我似乎无法转换合并 3 个字段 - ProductID
(NUMBER)
ProductCode
(文本),ProdDescription
(文本)
Dim strQuery As String = "SELECT ProductID, (CAST(ProductID AS TEXT) + ' - '
+ ProductCode + ' - ' + ProdDescription) AS [Prod]
FROM [FG - End Product Codes]
ORDER BY ProductCode;"
我也试过了
(CAST(ProductID AS VARCHAR(10)) + ' - ' + ProductCode + ' - ' + ProdDescription) AS [Prod]
和
(CONVERT(ProductID, TEXT)) + ' - ' + ProductCode + ' - ' + ProdDescription) AS [Prod]
和
(CAST(ProductID) AS VARCHAR(10)) + ' - ' + ProductCode + ' - ' + ProdDescription) AS [Prod]
和
(CAST([ProductID] AS TEXT) + ' - ' + [ProductCode] + ' - ' + [ProdDescription]) AS [Prod]
Error msg: System.Data.OleDb.OleDbException:
'IErrorInfo.GetDescription failed with E_FAIL(0x80004005).'
error code : -2147467259
我在另一个问题中看到了同样的错误,但他们的似乎有一些保留关键字问题,如果我的是一样的,我的保留关键字是什么,它在我的代码中的什么位置?
提前致谢
那是因为您尝试对使用 Access SQL 的 Access 使用 T-SQL。所以,试试这个:
Dim strQuery As String = "SELECT ProductID, ProductID & ' - ' &
ProductCode & ' - ' & ProdDescription AS [Prod]
FROM [FG - End Product Codes]
ORDER BY ProductCode;"
我正在使用 oledb 连接字符串将我的 asp.net 代码连接到访问数据库
我似乎无法转换合并 3 个字段 - ProductID
(NUMBER)
ProductCode
(文本),ProdDescription
(文本)
Dim strQuery As String = "SELECT ProductID, (CAST(ProductID AS TEXT) + ' - '
+ ProductCode + ' - ' + ProdDescription) AS [Prod]
FROM [FG - End Product Codes]
ORDER BY ProductCode;"
我也试过了
(CAST(ProductID AS VARCHAR(10)) + ' - ' + ProductCode + ' - ' + ProdDescription) AS [Prod]
和
(CONVERT(ProductID, TEXT)) + ' - ' + ProductCode + ' - ' + ProdDescription) AS [Prod]
和
(CAST(ProductID) AS VARCHAR(10)) + ' - ' + ProductCode + ' - ' + ProdDescription) AS [Prod]
和
(CAST([ProductID] AS TEXT) + ' - ' + [ProductCode] + ' - ' + [ProdDescription]) AS [Prod]
Error msg: System.Data.OleDb.OleDbException: 'IErrorInfo.GetDescription failed with E_FAIL(0x80004005).'
error code : -2147467259
我在另一个问题中看到了同样的错误,但他们的似乎有一些保留关键字问题,如果我的是一样的,我的保留关键字是什么,它在我的代码中的什么位置? 提前致谢
那是因为您尝试对使用 Access SQL 的 Access 使用 T-SQL。所以,试试这个:
Dim strQuery As String = "SELECT ProductID, ProductID & ' - ' &
ProductCode & ' - ' & ProdDescription AS [Prod]
FROM [FG - End Product Codes]
ORDER BY ProductCode;"