如何在vb.net中使用变量交互?

时间:2019-02-21 09:37:13

标签: sql vb.net variables

我正在尝试创建一个新应用,该应用使用SQL数据库根据用户输入/选择提取数据。 为此,我正在使用:

  • 1个显示项目的组合框
  • 1个组合框,显示查询表时要使用的可用列
  • 1个文本框,用户可以在其中输入数据以完成查询要求

我还使用参数来查询数据库,因为我发现这是正确的方法(避免任何有害的SQL注入攻击)。
到目前为止,子看起来像这样:

 Private Sub FindItem()
    SQL.AddParam("@item", "%" & TxtItem.Text & "%")
    SQL.AddParam("@project", "%" & cbxproj.Text & "%")
    SQL.AddParam("@column", "%" & cbxcol.Text & "%")


    loadgrid("Select
              SourceServer
             ,ProjectId
             ,ProjectName
             ,MasterTitle
             ,BugIdPrefix
             ,BugId
             ,BugTitle
             ,BugDescription
             ,EpicName
             ,Submitter
             ,AssignedByPerson
             ,IssueType
             ,Priority
             ,Severity
             ,PlatformFound
             ,ProgressStatus
             ,Resolution 
             ,CloseReason
             ,Feature
             ,SubFeature
             ,FoundVersion
             ,AffectedVersion
             ,FixVersion
             ,GameArea
             ,BuildFound
             ,BuildFixed
             ,ClFixed
             ,Component
             ,Label
             ,CurrentOwner
             ,TestType
             ,TimeEstimated
             ,TimeRemaining
             ,TimeLogged
             ,Studio
             ,TestTeam
             ,ScrumTeam
             ,createdtime_utc as 'Date Created'
             ,assignedtime_utc as 'Date Assigned'
             ,closedtime_utc as 'Date Closed'
             ,lastmodifiedtime_utc as 'Date Last Modified'
            From mydatabase where ProjectName like @project and @column like @item")
End Sub

因此,问题在于,如果我选择一个项目和一个列,然后按搜索按钮,则会显示结果。在文本框中输入一些文本后,将不会显示任何结果。

我在这里做什么错了?

0 个答案:

没有答案