title: Getting Data from SQL DB for ASP.NET Web Forms API
body: <p>I followed this tutorial (<a href="http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api" rel="nofollow">http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api</a>) for setting up a Web API in my ASP.NET Web Application. It doesnt, however, talk about how to retrieve records from a database. It instead hard coded dummy data into the controller, like this: </p>
  
  <pre><code>Product[] products = new Product[] 
      { 
          new Product { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 }, 
          new Product { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M }, 
          new Product { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M } 
      };
  </code></pre>
  
  <p>Let's say I have a table in my SQL DB called 'Products', how would I retrieve the product data from there instead? If anyone could point me in the right direction, I would appreciate it.</p>
  
  <p>I did try using a function but it didnt work.</p>
  
  <pre><code> DataTable dbProducts = new DataTable();
   dbProducts = Wrapper.getProducts();
  </code></pre>