iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 15, 2008
Reader Question - Would you host your client's work on your website?
About
 
May 15, 2008
How to Create an Ajax Autocomplete Text Field: Part 6
WebReference.com
 
May 14, 2008
Poll: Are the browser safe colors still needed?
About
 
May 14, 2008
Google Doctype launched
About
 
May 14, 2008
Web Editor Reviews - 6 New Reviews
About
 
May 14, 2008
Build Beautiful Buttons in Photoshop, Part I
SitePoint
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /ASP.NET

Database Development with ASP.NET WebMatrix 

  Views:    4496
  Votes:    2
by Anil Mahadev 12/06/03 Rating: 

Synopsis:

Database Development with ASP.NET WebMatrix
Pages: 
The Article

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.

Pages: 

Similar/related articles:


 
  Sponsors