如何使用OleDConnection从查询中获取多个值



我已经编辑了以前的代码,并在下面尝试过,我还将文本框更改为同名的列表框,但在运行下面的代码后,我现在在列表框中没有得到任何值:

myConnection.ConnectionString = providerEdit
Dim str As String
str = "SELECT [Email] FROM [PRD_Records] WHERE [ReceiveKMCWEMSAlerts] = Yes"
Using cmd As OleDbCommand = New OleDbCommand(str, myConnection)
  myConnection.Open()
  Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
  While reader.Read()
    txtCreateAnnTo.Text = reader(0).ToString
  End While
  reader.Close()
End Using

感谢大家的回复。。。。我发现了代码的问题,它非常简单,我只是忽略了它。我更新了下面的代码:myConnection.ConnectionString=providerEditDim str为字符串str="SELECT[Email]FROM[PRD_RRecords]WHERE[ReceiveKMCWEMSAlerts]=是"

    Using cmd As OleDbCommand = New OleDbCommand(str, myConnection)

        myConnection.Open()
        Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
        While reader.Read()
            txtCreateAnnTo.Items.Add(reader(0).ToString)
        End While
        reader.Close()
    End Using

相关内容

  • 没有找到相关文章

最新更新