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:
Using connection As New SqlConnection("Data Source=PathToDatabase.sdf;") Using command As New SqlCommand("SELECT Column1, Column2 FROM Table", connection) connection.Open() Using reader As SqlDataReader = command.ExecuteReader While reader.Read Dim lvi As New ListViewItem lvi.Text = CStr(reader("Column1")) lvi.SubItems.Add(CStr(reader("Column2"))) lvwPokeSelect.Items.Add(lvi) End While End Using End Using 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




Reply With Quote