-1

私は今このコードを持っています。しかし、それは 3 つのステップで失敗します。これを理解するのを手伝ってもらえますか??

失敗するポイントを3つ挙げました。

また、私が正しく行っているかどうかを検証してください。

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
4

2 に答える 2

0

SQL ステートメントでは、文字列を一重引用符で囲む必要があります。

strsql = "SELECT COUNT(*) FROM MetaSearchTags WHERE SearchTag = " & itm & ""

次のようにする必要があります。

strsql = "SELECT COUNT(*) FROM MetaSearchTags WHERE SearchTag = '" & itm & "'"
于 2013-07-17T00:01:21.423 に答える