如何将变量DIM输入到我的ms访问数据库中

时间:2017-11-28 23:15:59

标签: sql vb.net ms-access

我试图将声明为字符串的变量输入到我的访问数据库中。单击按钮时,#34; Ticket Status"未输入访问数据库。

    Dim str As String
    str = "update [tblUsers] set [Campus] = '" & cmboxCampus.SelectedItem & "' , [ProblemType] = '" & cmboxProblemType.SelectedItem & "', [IfOther] = '" & txtIfOther.Text & "', [Status] = '" & TicketStatus & "', [ProblemDescription] = '" & txtDescription.Text & "'  Where [Username] = '" & txtUsername.Text & "'"
    Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)

    TicketStatus = "Ticket being Assigned"

    If txtIfOther.ReadOnly = True And txtIfOther.Text <> "" Then
        MsgBox("When selecting 'other' please specify")
    End If

    If txtDescription.Text = "" Or cmboxCampus.SelectedItem = "" Or cmboxProblemType.SelectedItem = "" Then
        MsgBox("Please fill out all fields.", MsgBoxStyle.Information)
    Else
        Try
            cmd.ExecuteNonQuery()
            cmd.dispose()
            myConnection.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        MsgBox("Your ticket has been successfully submitted.", MsgBoxStyle.Information)
    End If
End Sub

0 个答案:

没有答案