我想根据其中一列中的值将excel电子表格中的某些列插入到sql中,我已经编写了sql代码,但是当我循环遍历代码时,它会不断添加一个新的querytbale。有没有办法将值插入到 sql 中用新值刷新查询表并将其插入到同一个 sql 表中?
sqlString = "Insert into table(fields) select '" & ws1.Cells(row, col) & "','" & ws1.Cells(row, co2) & "','" & ws1.Cells(row, col3) & "','" & ws1.Cells(row, col4) & "','" & ws1.Cells(row, col5) & "','" & ws1.Cells(row, col6) & "'"
Set destination = ws2.Range("A1")
Set pleasework = ws2.QueryTables.Add(conString, destination, sqlString)
sqlString = "Insert into table(fields) select '" & ws1.Cells(row, col) & "','" & ws1.Cells(row, co2) & "','" & ws1.Cells(row, col3) & "','" & ws1.Cells(row, col4) & "','" & ws1.Cells(row, col5) & "','" & ws1.Cells(row, col6) & "'"
Do
With pleasework
row = row + 1
.CommandText = sqlString
.Refresh
count = count + 1
End With
Loop While count < 5