Trying to display a value from Access Database to display onto ListBox on a form. The previous form sends this form a string which is 'prevval'- for reference to the code. Not entirely sure what the issue is? Please Help!! The QuestionID is technically a number but is it an issue if im making it a string because its being presented on the ListBox?
Error System.Data.OleDb.OleDbException (0x80040E10): No value given for one or more required parameters
Code:
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "SELECT QuestionID FROM tblQuestions WHERE (Topic='" + prevval + "')";
command.CommandText = query;
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
listQuestions.Items.Add(reader.ToString());
}
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
}