How to Create a Database in Visual Studio 2015

  1. Open Visual Studio and select New Project.
  2. In the New Projects window select ”Visual Basic” in the left-hand pane and “Windows Form Application” in the center pane. Name your application and click “OK”
  3. From the File sub-menu select “Save All” and save your project.
  4. From the Project sub-menu select “Add new item”.
  5. From the Add New Item screen, select “Common Items” in the left-hand pane.
  6. Scroll the center pane down until you see “Service-based Database”.
  7. Select “Service-based Database”. Name your database (making sure to preserve the “.mdf” extension) and click “Add”.
  8. From the View sub-menu select “Server Explorer”.
  9. In the Server Explorer pane expand “Data Connections”. Expand your database, right-click “Tables” and select “Add New Table”.
  10. Enter the fields for your database table.
  11. Locate the “CREATE TABLE” SQL statement in T-SQL pane. To name your database table, change “[dbo].[Table]” to “[dbo].[your database table name]”,and click “Update” button in upper left-hand corner of the dbo.Table[Design}tab.
  12. In the Preview Database Updates screen, click “Update Database”.
  13. In the Server Explorer pane, right-click “Tables” and select “Refresh”. Your database table should appear.
  14. In the Server Explorer pane, right-click your database table and select “Show Table Data”.
  15. In the dbo.yourtable [Data] tab, enter a few rows of data into your table.
  16. It appears you have to close down and reopen. Switch to the Form1.vb [Design] tab and from the Project sub-menu select “Add New Data Source...”
  17. In the Data Source Configuration Wizard, select “Database” and click “Next”.
  18. Select “Dataset” and click “Next”.
  19. Click “New Connection...”
  20. Select “Microsoft SQL Server Database File” and click “OK”.
  21. Browse to yourtable.mdf and click “OK”.
  22. From the File sub-menu click “Save All”.
  23. Or when you reopen (so back to 16) you can use Form1.vb[Design] and bring over
  24. The DataGridView and make it full which means click the middle button in the dock property
  25. Click on the little arrow at the top right of the DataGridView
  26. Under Choose Data Source pick add project data source.
  27. In the Data Source Configuration Wizard, select “Database” and click “Next”.
  28. Select “Dataset” and click “Next”.
  29. Click “New Connection...”
  30. Select “Microsoft SQL Server Database File” and click “OK”.
  31. Browse to yourtable.mdf and click “OK”.
  32. Test connection click ok
  33. Continue on until you get to Choose Your Database Ojects. Click on Tables to expand and click on the table or on fields if you only want specific fields. Then click Finish.
  34. You should now see the field names and the grid.
  35. When you run you should see the data.