Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 15th, 2008, 03:33 PM
Registered User
 
Join Date: Mar 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecting to MSSQL-- All about it

I'm just starting to learn ASP.NET (3.5) and I've gotten most of it down, but my failure to use a database is really crippling my learning ability.

How do I connect to MSSQL? I have Godaddy so they provide me with the username, password, url, etc. If I could get a few examples for the following it would really help ALOT!
 
  • Connect to database.
  • Retrieve all of the contents from a certain table.
  • Get an average from a table (or column, I can't quite remember which it would be).


I really have tried to get this down so don't think I'm just being a lazy person...I even went to the local Barnes and Nobles and bought Beginning ASP.NET 3.5 book to learn ASP. I just can't figure out how to connect to a database though :\

I would really appreciate it if you could give me an example and tell me how to display at least one of the processes above. I'm guessing I'll use the <script> method? As opposed to behind code?


 
Old May 16th, 2008, 02:23 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

It all depends on what you want to do, and how you want to do it. Beginning ASP.NET 3.5 covers accessing databases in chapters 11 through 14. It uses concepts like LINQ and the built-in web controls for data access.

The book Professional ASP.NET 3.5 digs deeper into "manual data access" using objects like Connections, DataReaders and DataSets.

You can also check out the ADO.NET quick starts:

http://www.dotnetjunkies.ddj.com/qui...soverview.aspx
http://quickstarts.asp.net/Quickstar...wcontents.aspx

Some of the guides may seem outdated, but most of the concepts still apply. For example, to access a database and get some data out, check out the SqlDataReader example:

http://www.dotnetjunkies.ddj.com/qui...ooverview3.src

There's a lot more information available, but it's difficult to give you precise pointers as I don't know what exactly you are looking for.

My book (and the Pro edition) is a good starting point to get familiar with the general concepts. Google and these forums would then your next step to get detailed answers to detailed questions.

Hope this helps; if not: please let me know.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old May 16th, 2008, 12:11 PM
Registered User
 
Join Date: Mar 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yea that helps Imar. I bought your book (ASP.NET 3.5) when I first decided I wanted to learn ASP and it really helped, so great job on it. I just bought the Professional edition several days ago, so I will look in there as I guess that's pretty much what I'm wanting to do...connect manually.

As far as what I'm trying to do, for now I just want to make a simple rating system so that I can call the data out of my database and average to a whole number, then display the number. I also need to write a simple bit of code that will add data to the database (the rating others have given it) so it will be added into later.

I did this on PHP easily using MySQL, but getting the whole database thing working in ASP has proven to be a challenge. If someone [u]wants</u> to write some sample code that would be excellent, but I'm definately not relying on someone to do so.

 
Old May 17th, 2008, 03:23 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You may want to take a look here:

http://p2p.wrox.com/topic.asp?TOPIC_ID=71354

It shows some basic code to connect to a database, execute a select statement and working with the results.

You may also want to take a look at chapter 8 of the Professional ASP.NET 3.5 book as it digs deeper into manually accessing databases.

From here, things should be similar to what you did in PHP. E.g. you calculate an average in your SQL statement or in .NET code and somewhere display the results.

If you have specific questions about some parts of the code, feel free to post them here.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
do we have to install MSSQL? angelboy C# 2005 4 January 19th, 2008 05:26 AM
MSSQL 2005 and MSSQL 2000 tiredcat Visual Basic 2005 Basics 0 April 9th, 2007 12:56 AM
uploading mssql database vickyj SQL Server 2000 1 May 20th, 2005 08:11 AM
Help!!!! MSSQL will not connect jts7979 Classic ASP Databases 1 December 12th, 2004 11:34 PM
MySQL and MsSQL stevenckh MySQL 2 September 12th, 2003 12:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.