Results 1 to 6 of 6

Thread: [RESOLVED] Not able to retrieve items from database

Threaded View

  1. #1

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Resolved [RESOLVED] Not able to retrieve items from database

    I'm using the SQL Server Compact Database and I'm trying to retrieve two columns of data and import that information into a ListView. This is my first attempt at using a database so I looked at JMC's code example, but I'm afraid I'm not getting it.

    Here's the code I'm using:

    VB.NET Code:
    1. Using connection As New SqlConnection("Data Source=PathToDatabase.sdf;")
    2.             Using command As New SqlCommand("SELECT Column1, Column2 FROM Table", connection)
    3.                 connection.Open()
    4.  
    5.                 Using reader As SqlDataReader = command.ExecuteReader
    6.                     While reader.Read
    7.                         Dim lvi As New ListViewItem
    8.                         lvi.Text = CStr(reader("Column1"))
    9.                         lvi.SubItems.Add(CStr(reader("Column2")))
    10.                         lvwPokeSelect.Items.Add(lvi)
    11.                     End While
    12.                 End Using
    13.             End Using
    14.         End Using

    I think there's something wrong with the command. Of all the information I looked up, none of it completely explained how those items were supposed to be entered, so I took form them what I could.

    Any information is appreciated.

    Thanks
    Last edited by weirddemon; Jan 29th, 2010 at 12:52 AM.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width