Just connect to a SQL table, and pull some data!

  • Thread starter Thread starter David Lozzi
  • Start date Start date
D

David Lozzi

It use to be so easy in ASP, but now in ASP.NET i'm lost and confused.

I'm trying to connect to a SQL database, open a table via a SQL string. Then
take the returning recordset and do what I want to it: pull two fields, pull
all fields, loop through the recordset, etc.

But i'm lost...
 
It use to be so easy in ASP, but now in ASP.NET i'm lost and confused.

I'm trying to connect to a SQL database, open a table via a SQL
string. Then take the returning recordset and do what I want to it:
pull two fields, pull all fields, loop through the recordset, etc.

But i'm lost...


Take a look at Microsoft's Data Access Application Block for .NET. These
classes should simplify data access greatly:

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/dnbda/html/daab-rm.asp

But basically you:

1. Connect to the database
2. Create a Command object
3. Populate the Command Connect with SQL and Connection
4a. Execute the command object to return a data reader
4b. Create a DataAdapter to fill a dataset

Choose A or B depending if you want a datareader or dataset.
 
Back
Top