检索到的access数据库数据不会显示在列表框中

时间:2016-01-18 11:52:23

标签: c# database visual-studio ms-access listbox

我正在尝试将存储在MS Acces数据库中的一些信息存入我的列表框。在运行以下查询时,我不会收到错误或其他内容,但它也不会显示列表框中的数据。

   connection.Open();
            try
            {
                string q = " SELECT Behandelingen.Behandeling FROM PatientBehandeling INNER JOIN Behandelingen ON PatientBehandeling.BehandelingID = Behandelingen.BehandelingID WHERE PersoonID = '" + textBoxUsername.Text + "'";
                command.CommandText = q;

                reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        listBox1.Items.Add(reader["Behandeling"].ToString());
                        listBox1.Refresh();
                    }

                }
                reader.Close();

            }

0 个答案:

没有答案