Apartment-Threaded Components Are Not SupportedBy default, components that use a single-threaded apartment (STA) model are not supported in an ASP.NET page. Furthermore, by default, the ASP Classic intrinsic interfaces, such as OnStartPage and OnEndPage , are not supported. If you want to use an apartment-threaded component, such as the ADO Connection object or the Scripting.Dictionary object, you need to add the following page directive to the top of the page: <%@ Page ASPCompat="true" %> For example, the following page displays all the records from the Titles table in the Pubs database using traditional ADO. If you don't enable ASP compatibility, the page fails. <%@ Page ASPCompat="true" %> <% Dim conPubs Dim rsTitles conPubs = Server.CreateObject( "ADODB.Connection" ) conPubs.Open( "Provider=sqloledb;UID=sa;PWD=secret;database=pubs" ) rsTitles = ConPubs.Execute( "Select * from Titles" ) While Not rsTitles.eof Response.Write( rsTitles( "Title" ).Value ) rsTitles.MoveNext End While %> |