我在Access中創建了數據庫,並給出了數據類型「短文本」。通過VB在Microsoft Access中插入多條記錄
現在我試圖通過Visual Basic提示記錄到此表中。我到目前爲止寫了一個代碼,但需要幫助來修復錯誤。我得到的編譯錯誤:
Duplicate declaration in current scope
我不知道它是什麼?
Option Compare Database
Sub arrayData()
Dim CustomerName() As Variant
Dim num As Integer, dbs As Database, InsertRecord As String
Dim CustomerID As Long, num1 As Long, CustomerName As String
Set dbs = CurrentDb()
CustomerID = 0
For num1 = 0 To 49999
CustomerID = CustomerID + 1
CustomerName = Array("Peter", "Mary")
CustomerAddress = Array("163 City Rd, SOUTHBANK", "65 Orange St, BENTLEIGH EAST")
CustomerPhoneAddress = Array("0416874963", "0478937534")
num = Int((200 - 0 + 1) * Rnd + 0)
CustomerName = CustomerName(num)
CustomerAddress = CustomerAddress(num)
CustomerPhoneNo = CustomerPhoneNo(num)
InsertRecord = "INSERT INTO Customers (CustomerID,CustomerName,CustomerAddress,CustomerPhoneNo) VALUES (" & "'" & CustomerID & "'" & "," & "'" & CustomerName & "'" & "," & "'" & CustomerAddress & "'" & "," & "'" & CustomerPhoneNo & "'" & ")"
dbs.Execute InsertRecord
Debug.Print CustomerID, CustomerName, CustomerAddress, CustomerPhoneNo
Next
End Sub
在這種情況下我該怎麼辦?任何幫助,將不勝感激。
那不是VB.NET代碼。 – Plutonix
兩個標籤中的兩個不正確 - 不錯! (固定) – YowE3K
你是什麼意思?你能給我解釋一下嗎? –