I forgot to inform u guys that those of you without IIS need not worry as it comes with its built in web server.
Now in this section, I have juiced up a special on Data Access for all of your out there.
So let’s develop that data access page!
When we start Web Matrix, we get our usual Start up window.
Select Data Pages and choose Simple Data Report as shown in Figure 1.1.

Fig 1.1
Once we have selected the type of data access page we want we go on do some editing to the page.
For this demonstration, I have changed the Simple Data report to Data Access with Web Matrix for Developer IQ.
And use the AutoFormat to give your report a more colorful look like in figure 1.2.
Fig 1.2
During this demo, I have used the Northwind Database and wish to display only the
CUSTOMER ID, CONTACT NAME, COMPANY NAME, CITY AND WHOSE
CITY NAME STARTS WITH THE LETTER “C”.
Interesting Uh!
Get ready to write some code.
I will now show you what to change in your code window. I have made slight changes to the code.
I will cut and Paste it here.
|
Sub Page_Load (Sender As Object, E As EventArgs)
“Changes to be made: Update the ConnectionString and CommandText values for your application”
Dim ConnectionString As String =
“server=(local)\NETSDK;database=NORTHWIND;trusted_connection=true”
Dim CommandText As String =
"SELECT CUSTOMERID,CONTACTNAME,COMPANYNAME,CITY FROM
CUSTOMERS WHERE CITY LIKE 'C%' "
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlCommand(CommandText, myConnection)
myConnection.Open()
DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
DataGrid1.DataBind()
End Sub |
In the above code, u folks need to change the server name to your local machine name or SQL Server named Instance.
In my case , I have installed MSDE 2000 and the .NET
Framework 1.1 SDK’s MSDE Named Instance , “NetSDK” .
We will next take a look @ what magic WebMatrix has for us.
Next Press F5 and watch the wonders of this beautiful tool like in Figure 1.3.
Fig 1.3
So I hope this tutorial was fun and that you will try it out and will benefit from building awesome data access web apps using WebMatrix.
So, thank you once again for your patience and continued Support. Please e-mail me on any questions you may have concerning this article.
For Code Downloads, please visit
http://www24.brinkster.com/anilmahadev/index.aspx
and click on ASP.NET WebMatrix Article Part 2
So , in the next issue of this wonderful series, we shall see on how to create a Database within WebMatrix and create tables, give appropriate keys and other interesting stuff.
Microsoft ASP.NET WebMatrix Logo, The .NET Framework, SQL Server and other Trademarks are Copyright of Microsoft Corporation and other International Countries, wherever applicable.