sql - “通过”VBA 附近的语法不正确
问题描述
我收到一个错误
“通过”附近的语法不正确
(可能缺少一些空格逗号?),没有任何进一步的细节。
你能帮我么?
非常感谢贾娜
Private Sub CommandButton1_Click()
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Driver={SQL Server};Server=.;Database=P;Uid=ss;Pwd=In;"
Dim rng As Range: Set rng = Application.Range("A2:N2")
Dim row As Range
For Each row In rng.Rows
dis = row.Cells(1).Value
ret = row.Cells(2).Value
dis_country = row.Cells(3).Value
ret_country = row.Cells(4).Value
ph1 = row.Cells(5).Value
flag = row.Cells(6).Value
kpi = row.Cells(7).Value
Group = row.Cells(8).Value
Value = CDbl(row.Cells(9).Value)
fiscal_quarter = row.Cells(10).Value
qtr = CDbl(row.Cells(11).Value)
week = CDbl(row.Cells(12).Value)
timestamp = CDbl(row.Cells(13).Value)
UserID = row.Cells(14).Value
Sql = "insert into [IMPORT].[tb] values('" & dis & "'," & ret & " ," & dis_country & " ," & ret_country & " ," & ph1 & " ," & flag & " ," & kpi & " ," & Group & " ," & Value & " ," & fiscal_quarter & " ," & qtr & " ," & week & " ," & timestamp & " ," & UserID & ")"
con.Execute Sql
Next row
con.Close
MsgBox "Done"
End Sub
解决方案
推荐阅读
- asp.net-core-3.1 - 如何在 .NET Core 3.1 Azure Web App 中获取关机原因
- reactjs - 无法读取未定义的属性“环境”
- c# - 在 Management Studio 中工作但在 Visual Studio 中不工作的相同 SQL 查询
- javascript - 在 JavaScript ES5 中对数组进行子类化
- r - Mac 10.9.5 上的 R 3.3.3 安装 devtools 包时遇到问题
- azure - 使用连接数据类型的慢速 Elasticsearch 索引
- javascript - Material UI 样式在组件中不起作用(警告:`@material-ui/styles` 的多个实例)
- python - Psycopg2 无法创建表
- android - 防止在 Zoom Android SDK 上截屏
- reactjs - 无法使用 useState 处理反应微调器加载