Getting data from MS Access database and display it in a listbox

后端 未结 7 802
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 06:37

How do I read data in ms access database and display it in a listbox. I have the codes here but i got errors.

 private void button3_Click(object sender, Even         


        
7条回答
  •  無奈伤痛
    2020-12-11 07:04

    GetString() takes an int as the parameter and not a string. Meaning that you must use the index of the column.

    In your specific circumstance as "FirstName" is the second column the index would be 1:

    listBox1.Text = Reader.GetString(1);
    

    http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdatareader.getstring.aspx

提交回复
热议问题