我現在有這個代碼。但它失敗了三個步驟。你能幫我弄清楚嗎?VB.net表迭代
我列出了失敗的三點。
也請爲我驗證如果我做對了嗎?
Retrieve the string from the tb_metatags textbox
Dim s As String
s = Me!tb_metaatags
parse the string into substrings by looking for the commasDim arrLines() As String
Dim arrLines() As String
arrLines = Split(s, ",")
For each substring, check if the substring is in the MetaSearchTags table
Dim itm As Variant
For Each itm In arrLines
Dim strsql As String
Dim numrows As Integer
strsql = "SELECT COUNT(*) FROM MetaSearchTags WHERE SearchTag = " & itm & ""
Dim objcmd As New OleDbCommand(strsql, conn) "I get an error here
numrows = objcmd.ExecuteScalar
If numrows > 0 Then
MsgBox("Record Exists", vbInformation, "Add") "I get an error here
Else
Dim myadapter1 As New OleDbDataAdapter("INSERT INTO MetaSearchTags (SearchTag) "VALUES ('" & itm & "')", conn) "I get an error here
Dim mytable1 As New DataTable
myadapter1.Fill (mytable1)
End If
if it is not already in the MetaSearchTags table, then add it to the table
get the primary key (ID) for the substring from the MetaSearchTags table
Add an row in the MetaSearchTagAssignments table for this search tag
using the projectID, and the substring ID from the MetaSearchTags table
Repeat this process for each substring entered in the field
如果你用撇號評論你的筆記會更好,所以有人可以複製並粘貼你的代碼。您還需要確認收到的完整錯誤消息。 –
完全刪除了最後一段的代碼格式,因爲它是文本段落,並且與代碼無關。請[編輯]它,以便閱讀(和複製/粘貼)更容易。此外,當你在這裏時,發佈關於「我得到一個錯誤」的細節的含義,因爲「我得到一個錯誤」沒有關於「錯誤」的細節沒有意義。每個人都有錯誤信息;請分享它,因爲我們無法從這裏看到它們。 :-) –
這條線上的錯誤是什麼? 'Dim myadapter1 As New OleDbDataAdapter(「INSERT INTO MetaSearchTags ...' –