1

所以我创建了这段代码(可能甚至不必显示它 - 但以防万一!),因为我在第一行得到“用户定义的类型未定义”,所以无法对其进行测试。我看到我应该在工具>参考中设置参考,但该选项是灰色的...。

Sub UploadDistributors()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset

strConn = "Provider=SQLOLEDB-Removed for security-Network Library=DBMSSOCN"

cnn.Open strConn 

Dim k
k = 0

   For i = 1 To 352

   sSQL = "INSERT INTO DistributorsNP (CompanyName, address, city, state, zip, phone,    tollfree) VALUES ("

    'CompanyName
    sSQL = sSQL & Sheet1.Range("B" & i).Value & ","
    'address
    sSQL = sSQL & Sheet1.Range("C" & i).Value & ","
    'city
    sSQL = sSQL & Sheet1.Range("D" & i).Value & ","
    'state
    sSQL = sSQL & Sheet1.Range("E" & i).Value & ","
    'zip
    sSQL = sSQL & Sheet1.Range("F" & i).Value & ","
    'phone
    sSQL = sSQL & Sheet1.Range("G" & i).Value & ","
    'tollfree
    sSQL = sSQL & Sheet1.Range("H" & i).Value & ","



sSQL = sSQL & ")"
rs.Open sSQL, cnn, adOpenStatic, adLockReadOnly, adCmdText

rs.Close

Next

End Sub
4

1 回答 1

2

猜你已经在编辑器中按下停止并且不再处于中断模式......?

于 2013-01-07T15:47:36.747 回答