如何使用 OleDBConnection 从查询中获取多个值?
How do I get multiple values from query using OleDBConnection?
我编辑了以前的代码并在下面尝试了这个,我还将文本框更改为具有相同名称的列表框,但是我现在在 运行 下面的代码之后在列表框中没有任何值:
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 = providerEdit
将 str 调暗为字符串
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.Items.Add(reader(0).ToString)
End While
reader.Close()
End Using
我编辑了以前的代码并在下面尝试了这个,我还将文本框更改为具有相同名称的列表框,但是我现在在 运行 下面的代码之后在列表框中没有任何值:
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 = providerEdit 将 str 调暗为字符串 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.Items.Add(reader(0).ToString)
End While
reader.Close()
End Using