Apartment-Threaded Components Are Not Supported


Apartment-Threaded Components Are Not Supported

By 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 %> 


ASP.NET Unleashed
ASP.NET 4 Unleashed
ISBN: 0672331128
EAN: 2147483647
Year: 2003
Pages: 263

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net