0
我想插入Excel電子表格中的某些列到基於其中一列中的值的sql中,我已經編寫了sql代碼,但是當我通過它繼續添加的代碼循環時一個新的querytbale。有沒有辦法將值插入到SQL刷新查詢表與新值並插入到相同的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