Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all

I'm trying to fill the ListBox with selected student's name. Instead I have the ListBox fill with System.Data.DataRawView

 

Here is my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

   Dim thedata As DataSet
       Dim theAdapter As OleDb.OleDbDataAdapter
       Dim connectstring, sqlstr As String
       connectstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My Documents\student.mdb"

      sqlstr = "Select * from Student"
       thedata = New DataSet()

       Dim Student As DataTable = thedata.Tables.Add("Student")

       theAdapter = New OleDb.OleDbDataAdapter(sqlstr, connectstring)
       theAdapter.Fill(thedata, "Student")
       ListBox1.DataSource = thedata.Tables("Student")
       ListBox1.DisplayMember = "Studentname"
End Sub 

Posted (edited)

Dear Robby and Casio

I added where clause but instead of showing Smith in my list box, it is showing System.Data.DataRawView

Edited by JAM
Posted

Thank you all

I have it fixed. I had to add this line

 

Dim Studentname as datacolumn = Student.columns.Add("Studentname")

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...