如何根据ListBox中显示的第一个字段获取第二个字段

时间:2017-11-16 20:37:44

标签: vb.net

我有一个ListBox,它从SQL Server表中读取数据。该表只有两个字段;第一个是报告名称,第二个是我想要在GridView中执行和显示的SQL。我的代码看起来像这样。

    myItem = ListBox1.SelectedItem
    SqlStr = "select ReportSQL from [All_Report_Names] Where ReportName = '" & myItem & "'"

    SqlStr = Replace(SqlStr, startDate, VBstartDate)
    SqlStr = Replace(SqlStr, endDate, VBendDate)

它几乎就像是:myItem = ListBox1.SelectedItem.Offset(0,1)

当然这不起作用。

ListBox指向此SQL Server表。

enter image description here

第一个字段显示在ListBox中。当我点击它时,我想阅读seconf列,它包含我所有的SQL脚本。最后,我在startDate和endDate上执行REPLACE(),并将我的Form中的那些传递给SQL。

ListBox从下面的SQL Server表中读取。

0 个答案:

没有答案