<!-- Article image -->
<!-- Add the rest of your HTML here -->
Some time ago I implemented a data feed
system from SQL database to some graphical applets. At the
beginning we decided a normal ASP script which read data and gave it to that
applets would be useful. Unfortunately it wasn't! The web
server was crashed every time the number of simultaneous users on the site was
more than 80-100 users and when an user tried to get larger data in an
applet. For those reasons we decided to move the feed to ISAPI dll.
- the ASP server is freed by the calls from clients applets. In that way
the asp will respond only to the normal site calls; the asp will not
produce any timeouts caused by applets calls.
- keeping the connection to the DB in the ISAPI cache, in that way all requests
against DB don't loose time opening a connection, and will use the
public open connection variable (
- The ISAPI extension dll are the best choice if you want to obtain the maximum
number of simultaneous connections to the IIS web server or to provide huge
quantities of HTML data.
The ASP script loads the applet class
and gives it some parameters, like colors, time interval of http's requests, web application URL, etc.
archive="../AspDemoFeed/Tools/OnlineScroll/Scroller.jar" code="ScrollerStartUp.class" width="600"
height="20" VIEWASTEXT id="Scroller">
param name="speed" value="3"
param name="bgcolor" value="696969"
param name="Font" value="Arial|1|16"
param name="changeFontSize" value="11"
param name="feedURL" value="<%=Application("WebURL")%>cgi-bin/IsapiDemoFeed.dll?GetOnlineScrollerData?"
param name="updateInterval" value="20000"</applet>
The java applet will make requests from the client's side to the web
server HTTP using the
received web URL
parameter. The requests are madedat equal intervals of time given in
milliseconds by the
updateInterval parameter. If you open the java console on the client
you will see some messages like:
Loading data from
The ISAPI module responds to the HTTP hit with a format known by
the applet, html stream:
For each HTTP hit, the ISAPI
module makes a request again to the SQL database, using the
classes from CodeProject site :).
minor modification was to keep the database connection as public
variable. In each method the record sets needed are opened and closed. An
optimization is the use of
of the AdoRecordset class, which returns formatted data text. Because the ISAPI dll is harder to debug, more attention must be
given to capturing errors,
CAdoRecordset* AdoRS = new CAdoRecordset;
if ( DBConnectionOpen( m_bstrConnectionString ) )
if ( AdoRS->Open(m_AdoDB.GetActiveConnection(), bstrSTMT, adOpenForwardOnly,
adLockReadOnly, adUseClient ) )
varOutput = AdoRS->GetString("|", "\n", 0 );
varOutput = "0 0 0 0 0 ";
(LPCTSTR)m_AdoDB.GetLastError(), "RS isnt open", bstrSTMT );
*pCtxt << wcOut ;
wsprintf(wcOut, "Encountered Error:<br>%s<br>%s<br>%s<br>%s<br>","GetMarketMapData",
(LPCTSTR)m_AdoDB.GetLastError(), "DB isn't open", bstrSTMT );
*pCtxt << wcOut ;
wsprintf(wcOut, "Encountered Error :<br>%s<br>%d<br>%s<br>", (LPSTR)err.Description(),
err.Error(), (LPSTR)err.ErrorMessage() );
*pCtxt << wcOut ;
*pCtxt << varOutput;
IMPORTANT: To test the feed, you must
make updates on the values of the
* tables. The updates will be reflectied online instantaneously
in the Online tables and scrolling applets. To see how it works with Intraday
charts applets make inserts in
tables. Those applets look permanently at those tables and updates the
values in cells and points on the charts.
ASP connection string are located in the
cnx.Provider = "sqloledb"
<BR>cnx.Open "Data Source=andi;Initial Catalog=ArticlesIsapiFeed;", "sa", ""
ISAPI connection string are located in IsapiDemoFeed.cpp file, on
Source=andi;Initial Catalog=ArticlesIsapiFeed;<BR>User ID=sa;Password=;";
- Copy the folder "AspDemoFeed" under your
web site and make it ASP application, to work the session and
- Give "Scripts and Executables" Execute
Permision to "cgi-bin" directory of
"AspDemoFeed" web application.
In that way the ISS web server will be able
to execute the IsapiDemoFeed.dll.
- To install the database on your SQL server select restore database option on
SQL Server Enterprise Manager and choose
file backup. The name of database is ArticlesIsapiFeed.