![]() |
Home > ASP > Databases |
|
|
|
A pre-requisite for performing database operations is connectivity to the database. From ASP, this is done through the use of a provider string. A provider string contains all the necessary information to allow the database driver to connect to the database. It contains the following information:
Here is an example provider string:
<%
strProvider = "provider=sqloledb;data source=database_machine.developer.4mg.com;uid=myusername;pwd=mypw;database=mydatabase"%> |
Queries are executed using an object of type ADODB.Recordset. The following code sample shows how a recordset is created, using the results from a query.
<!--#INCLUDE FILE="adovbs.inc" --> <% strProvider = "provider=sqloledb;data source=database_machine.developer.4mg.com;uid=myusername;pwd=mypw;database=mydatabase"%> |
Once a query has been executed, the results can be processed. Results can only be accessed one row at a time, and the data in each column can be accessed using a numeric column index (0 is the left-most column index), or the column alias name.
The following code sample illustrates this process.
<!--#INCLUDE FILE="adovbs.inc" --> <% strProvider = "provider=sqloledb;data source=database_machine.developer.4mg.com;uid=myusername;pwd=mypw;database=mydatabase"%> |
An SQL query will return results that are the same length as the space allocated in the database, regardless of how much space is actually occupied by the data. Therefore, the RTrim function is used to remove the trailing whitespace (spaces & tabs) from the right-hand end of the string argument passed to it.
Search | Sitemap | Disclaimer | Contact Webmaster © Copyright DevNet 2001, All rights reserved. Reproduction in any form without prior written permission from the owner is expressly prohibited. |