Tag: sql server express

使用VBA在Excel中查询SQL Server表

我想使用VBA在Microsoft Excel中查询表格。 我已经写了一些代码来尝试完成这个任务,但我不断收到一个错误: 运行时错误'1004':说这是一个通用的ODBC错误。 我不知道我需要做什么才能让这个代码正常运行,所以我可以查询这个表。 我正在使用SQL Server Express,即我连接的服务器: .\SQLEXPRESS 数据库: Databaselink 查询产品表VBA代码: Sub ParameterQueryExample() '—creates a ListObject-QueryTable on Sheet1 that uses the value in ' Cell Z1 as the ProductID Parameter for an SQL Query ' Once created, the query will refresh upon changes to Z1. Dim sSQL As String Dim qt As QueryTable Dim […]