+ All Categories
Home > Documents > 1 - HOW TO CREATE A DATABASE, DATASOURCE and CONNECTION.docx

1 - HOW TO CREATE A DATABASE, DATASOURCE and CONNECTION.docx

Date post: 18-Jan-2016
Category:
Upload: neaehlyn-saelaezaer-hernaendez
View: 235 times
Download: 0 times
Share this document with a friend
Popular Tags:
5
HOW TO CREATE A DATABASE 1. Create a new item by clicking this icon or simply by pressing Ctrl + Shift + A. The Add New Item dialogue box will appear as follows: 2. Make sure that Visual Basic is selected at the right panel then search and select SQL Server Database on the list at the center panel. Change (if desired) the database name at the text field at the bottom part of the window. Click Add when finished. 3. A dialogue box will then appear as follows:
Transcript
Page 1: 1 - HOW TO CREATE A DATABASE, DATASOURCE and CONNECTION.docx

HOW TO CREATE A DATABASE

1. Create a new item by clicking this icon or simply by pressing Ctrl + Shift + A. The Add New Item dialogue box will appear as follows:

2. Make sure that Visual Basic is selected at the right panel then search and select SQL Server Database on the list at the center panel. Change (if desired) the database name at the text field at the bottom part of the window. Click Add when finished.

3. A dialogue box will then appear as follows:

Click ‘Yes’ here. If you do not have an ‘App_Data’ folder, it will be created containing the database you will be constructing.

Page 2: 1 - HOW TO CREATE A DATABASE, DATASOURCE and CONNECTION.docx

4. For you to be able to see your database, click the View menu then select Server Explorer. The said panel will then be viewed on the left side of the window as follows.

5. Add a new table by right clicking the Tables folder on the Server Explorer. This procedure will look like the figure shown below:

6. When the table is created it will initially be shown on screen. You may now enter the field names of the table you just have created. It will look just as follows:

Page 3: 1 - HOW TO CREATE A DATABASE, DATASOURCE and CONNECTION.docx

HOW TO VIEW RECORDS IN THE DATABASE

1. Create a new Web Form by clicking this icon or simply by pressing Ctrl + Shift + A. Once the web form is created, drag and drop a GridView onto the body of the page. Drag and drop a SqlDataSource to set the database from which it will be connected.

2. Configure your SqlDataSource by clicking on the arrow at the upper right corner of the object. It looks like the figure below:

Click on the hyperlink Configure Data Source and the Configure Dialog Box will appear. Choose the database that you just have created and click Next. The next window will ask if you want to save the connection string as that name. Check the tick box and click Next. The next window will ask you to specify the columns in the table that you want to be viewed. By default, “*” is checked meaning “all the mentioned tables”. Click Next. The next window will test the query created. If you see table titles like the one shown on the figure below, then you are sure that your database is connected, then click Finish.

3. Connect the GridView with the Data Source you created by clicking on the arrow at the upper right corner of the object. It will look just as follows. Select the data source you created.

Page 4: 1 - HOW TO CREATE A DATABASE, DATASOURCE and CONNECTION.docx

4. You may also change the way this table looks by clicking on the Auto Format link at the top and window with options will appear. The following shows a table with a Professional option as its design and the paging, sorting and selection are all enabled.

5. To be able to add records on the database, go to the View menu and select Server Explorer or simply press Ctrl + Alt + S. The Server Explorer will appear. Right click the table you created and select Show Table Data.

6. You may now add records on the table and save changes.


Recommended