title: VB.NET Local Database Connection/Data Extraction
body: <p>I've been looking over a bunch of code snippets and I'm just not understanding what is going on there. Some help in understanding the connection, reading/manipulation, and closing process would be more than appreciated.</p>
  
  <p>I keep reading all about these DataAdapters, Ole and Sql and Sqlce and I don't know which to use or whatever.</p>
  
  <p>I made a database in VB.NET 2010 that came out as database.sdf and I selected the Local Database option (I assume this is relevant?). I then populated the database with a row of data with column titles and a primary key. The table contains many different columns, but for test purposes, the following is relevant:</p>
  
  <ul>
  <li>DB Name: db_test</li>
  <li>Table Name: Locations</li>
  <li>Primary Key Column Header: CITY</li>
  <li>Another column: BOUND_X</li>
  <li>Info in those two cells: CITY - 'Brunswick' and BOUND_X - '5'</li>
  <li>There is only one row of data, so this
  is either Row(0) or Row(1), because I don't know what .NET uses for its start index.</li>
  </ul>
  
  <p>This is what I pieced together, but I'm quite sure it's just not even in the right direction... </p>
  
  <p>Obviously code help would be phenomenal, but if anyone is willing to break this process down in English as well, that'd be super fantastic.</p>
  
  <pre><code>Dim conn As SqlConnection = New SqlConnection("Data Source=G:\Programming\VB.NET\TEST\TEST\db_test.sdf")
  
  Dim ds As New db_test
  Dim sql As New SqlCommand("SELECT * FROM Locations WHERE CITY='Brunswick'")
  
  conn.Open()
  
  (I have no idea what this is actually referring to, I am just trying to read data with these commands below that seemed to pop up a lot in forums...)
  Dim sdr As SqlDataReader = sql.ExecuteReader
  While sdr.Read = True
      MsgBox(sdr.Item("CITY") &amp; " " &amp; sdr.Item("BOUND_X"))
  End While
  
  sdr.Close()
  
  conn.Close()
  </code></pre>