Program with Web Matrix

Unknown | 19:35 | 0 comments

hello world on web matrix





Simple database connection using webmatrix IDE:
Webmatrix is a simple development environment   developed by microsoft people today we are going to learn simple database program using web pages with razor syntax in webmatrix ide
Steps:
       1. Launch web matrix ide !
       2. Choose open site and select empty site!
              3. Give site name of your choice(ide will create some default files)!
       4. Inside default.cshtml write according to following algorithm
        START
        4.1. Open database(initialize database connection ).
        4.2. Write sql query of your choice store it in variable.
        4.3  Print  query response using loop or with own logic
        STOP
        5. Keep coding!
Sample Program:
@{
var db = Database.Open("dbname"); //database connectionvar QueryString = "SELECT * FROM tablename"; //sql query}
<html> <body> <h1 >Heading</h1> <table> <tr>
<th>employeenumber</th> <th>employeename</th> <th>employeesal</th> </tr>
@foreach(var row in db.Query(QueryString))
{
<tr> <td>@row[0]</td> <td>@row[1]</td> <td>@row[2]</td> </tr> }
</table> </body> </html
            !Thank you!

Category: ,

handsonbook.blogspot.com

0 comments