'Code error "expression does not produce a value" in visual basic 2022
When I am trying to read data from an MS Access database into a combo box in Visual Basic 2022, I received the error " Crdr_1.Read - expression does not produce a value". What might be the cause and how to solve it.
Here is the code:
Private Sub Create_New_Project_load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim conn_1 As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Windows.Forms.Application.StartupPath & "\Country_Codes_Database.accdb")
Dim ConCode As New OleDbCommand("select * from Country_Names_Codes", conn_1)
conn_1.Open()
Dim Crdr_1 As OleDbDataReader = ConCode.ExecuteReader
ComboBox_ProjectCountry.Items.Clear()
While Crdr_1.Read
ComboBox_ProjectCountry.Items.Add(Crdr_1.GetString(1))
End While
conn_1.Close()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
