Basic Databases Part 1
page 3 of 4
by . .
Feedback
Average Rating: 
Views (Total / Last 10 Days): 25215/ 70

Step 2 : Get my data!

Step 2: Get my data!

Now we've got our connection all sorted, we'll work on getting the data. Getting data doesn't mean storing it into a variable, it needs to be stored in a RecordSet. A RecordSet makes it eaisier to view data because it stores it like a table, in rows. There are several methods of using a RecordSet to get data, this is the best, because you only need 1 variable (becomes an object).

set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = objConn
Recordset1.Source = "SELECT * FROM Customers"
Recordset1.Open()

You know about the first line but then we set object properties that are then used when we call the Open() method. First we tell it where to get the connection, and because objConn already has one open, why not use it? Next we give it a SQL statement. Finally we call the Open() method. The open method basically uses the connection, asks the database for the data which matches the SQL string and stores it in itself. A recordset is a truly useful object, but it only stores 1 table. In ASP.NET they replaced RecordSet with DataSet which can hold more than 1 (See ASP.NET & Data ). You also must think of a RecordSet as a normal database table.


View Entire Article

User Comments

Title: SQL SERVER 2000   
Name: Anchal
Date: 2005-03-17 12:49:41 PM
Comment:
This is a great help for me...as I am just starting up with ASP and DATABASE and ADO

one thing...example you took is based on MS ACCESS...
Would it be similar for the MS SQL SERVER 2000???

Please Advice...it would be a great help..

Anchal
Title: Connection error   
Name: lumy
Date: 2005-03-01 8:59:52 AM
Comment:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/currency/respond.asp, line 33

Please assist.
Title: Great Help   
Name: Rizwan
Date: 2005-01-15 4:16:22 AM
Comment:
This is really great help for newbies, also for those who forget forget the logical procedure of database programing.
Thanks you Mr. Author!

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-12-07 7:58:10 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search