Article ID: 169377 - Last Review: November 20, 2006 - Revision: 10.4 How to access SQL Server in Active Server PagesThis article was previously published under Q169377 On This PageSUMMARYThis article describes how to establish connections to SQL
Server in an ASP script by using ActiveX Data Objects (ADO), while taking
advantage of the connection pooling feature of ODBC 3.0. MORE INFORMATIONConnection PoolingEnable ODBC connection pooling.For additional information about connection pooling and for instructions about how to enable this feature, click the following article number to view the article in the Microsoft Knowledge Base: 164221
(http://support.microsoft.com/kb/164221/
)
How to enable connection pooling in an ODBC application
ODBC DSNUsing the ODBC Administrator, create a System data source name (DSN) on the computer where Microsoft Internet Information Server (IIS) is installed. Specify the connection attribute one time, and then reuse it on every page. For example, in the Session_OnStart event in Global.asa file, define the connection attribute as:
Microsoft OLE DB provider for ODBC Drivers error '80004005' [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed- User: _ Reason: Not defined as a valid user of a trusted SQL Server connection. Global.asaUse of the Global.asa file is optional. In its place, entries typically made in this file can be put on the first page called by the application. Assuming the ASP scripts are located in a folder that is not defined as a virtual directory in the Internet Service Manager, but below another virtual directory, the Global.asa file containing Session variables and DSN definitions must be kept in the virtual directory. Otherwise, you receive the following error message:Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified Connections in the ASP ScriptTake advantage of connection pooling by opening and closing the connection to the database on every active server page. To open the connection, type the following statements in the <Body> section of the page:Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC SQL Server Driver][DBNMPNTW]Connection broken. -or- Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC SQL Server Driver]Communication link failure Here is a sample application that consists of the Global.asa and the Authors.asp files. This sample application will return four columns and all the records in the pubs table named authors. Note You must change UID <username> and pwd =<strong password> to the correct values before you run this code. Make sure that UID has the appropriate permissions to perform this operation on the database. Global.asa REFERENCES Didn't see an answer to your question? Visit the
Microsoft SQL Server Newsgroups at:
Microsoft
SQL Server Newsgroups
(http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.sqlserver.server)
Comments about this or other
Microsoft SQL Server Knowledge Base articles? Drop us a note at
Q169377
(mailto:sqlkb@microsoft.com?Subject=Q169377)
APPLIES TO
| Article Translations
|

Back to the top
