Within last weeks tutorial I learnt how to create and mine a SQL database. This task was fairly confusing, but managed to give the correct output once completed.
To start the process I initially followed the standard steos required to create a database, including creating a New Project, linking to the SQP database, choosing C# and defining the location. This created the basic core layout for the database. Adding a new web form was the next task, followed by creating a database in the App data (this was done by right clicking on the directory name and adding a new SQL Server Database). The remaining steps are as follows:
- Choosing Server Explorer, Database Designs then right clicking on Tables and choosing "Add New Table" - this then gave me the ability to add a new table into the database.
- The next step was to add a column name and define the data type (nVarChar 50 etc.), avoiding using spaces between the words within the column title. Ant saving to the table is done automatically when the table is closed.
- Right click on table in Tables (Toolbox) and select "Show Table Data". To make changes, right click on table name and choose "Open Table Definition".
- Primary keys can be applied to a particular column name by right clicking on column name and defining it to be the primary key - this process must be done though before adding the table to the database.
- The next stage is to add a Drop Down List into the design view (it will currently be unbound).
- Choose Data Source and select a New Data Source. Choosing the SQL database is the next stage, followed by defining a connection method to the database. This connection should then be saved once defined.
- From the data source, select the "*", which will choose all column names from the table. Testing the query should then result in all the records appearing. Click Finish. State DropDown options. Click Finish. The object should now be databound.
- All connections are held within the webconfig file in the system.
- The next stage is to add a GridView from the Data option in the Toolbox. Choosing the Data Source as SqlDataSource 1 or SqlDataSource2 will provide a connection between the newly inserted option and the table.
- The names of the column headings should now be inserted into the object.
- Previewing in browser is a good text to see if it has worked.
- Select the arrow in the corner of Grid View and choose Auto Format to define a style - using a simple one is better for this exercise.
- Enable sorting (optional)
- Enable paging (optional)
- Enable selection (optional)
- Clicking on column headings will sort the order once viewed in a browser.
- Properties enable other types of formatting that can be applied to the table.
- Select the arrow in the corner of the GridView and choose ConfigDataSource, click next and then advanced, click Generate then next, and then choose WHERE > StudentID = Control > DropDownList1. Click Add, OK, Next, Test, Finish.
- These statements bring bacj information relating to ta piece of information about a student.
- Show data where students have the same piece of information in drop down list.
- Enable AutoPostBack.
Monday, 13 December 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment