<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OmanDev &#187; asp</title>
	<atom:link href="http://www.omandev.net/tag/asp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.omandev.net</link>
	<description>Technical, computer related articles and projects.</description>
	<lastBuildDate>Sat, 17 Jul 2010 18:54:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adding a friendly splash (waiting screen) while the code is being executed in ASP</title>
		<link>http://www.omandev.net/2008/08/adding-a-friendly-splash-waiting-screen-while-the-code-is-being-executed-in-asp/</link>
		<comments>http://www.omandev.net/2008/08/adding-a-friendly-splash-waiting-screen-while-the-code-is-being-executed-in-asp/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 15:15:00 +0000</pubDate>
		<dc:creator>Arkan Hadi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[activity]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[borwser]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[flush]]></category>
		<category><![CDATA[indicator]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[loading]]></category>
		<category><![CDATA[please wait]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[splash]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[waiting screen]]></category>

		<guid isPermaLink="false">http://66.147.242.194/~omandevn/wrd1/wordpress/?p=37</guid>
		<description><![CDATA[Nowadays, most websites are connected to databases. the larger the data in the database, the longer it takes for the browser (or the code) to fetch/retrieve the required data for the user. and ofcourse, that&#8217;s where the developers&#8217; skills comes handy, where developing an efficient code and using the minimum queries as possible is a [...]


Related posts:<ol><li><a href='http://www.omandev.net/2008/08/increasing-performance-and-adding-flexibility-using-arrays-instead-of-recordsets-in-asp-with-databases/' rel='bookmark' title='Permanent Link: Increasing performance and adding flexibility using arrays instead of recordsets in ASP with databases'>Increasing performance and adding flexibility using arrays instead of recordsets in ASP with databases</a></li>
<li><a href='http://www.omandev.net/2008/08/calling-asp-functions-from-java-script/' rel='bookmark' title='Permanent Link: Calling ASP Functions from java script'>Calling ASP Functions from java script</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Nowadays, most websites are connected to databases. the larger the data in the database, the longer it takes for the browser (or the code) to fetch/retrieve the required data for the user. and ofcourse, that&#8217;s where the developers&#8217; skills comes handy, where developing an efficient code and using the minimum queries as possible is a must. i would like to add that having a little data in the database is not an excuse for not developing an efficient code for retrieving information from databases.</p>
<p>now, i assume that you &#8220;developers&#8221; did the most efficient way to retrieve the data, but above that there is still a considerable &#8220;fetching&#8221; time to wait inorder to fully display the records queried, here comes the benefit of adding a splash screen for the user, so he/she doesn&#8217;t panic and think that the page is stuck or something.</p>
<p>easy steps to follow inorder to get an attractive waiting screen (see below) while the code is processing and the user is waiting:<br />
<a href="http://3.bp.blogspot.com/_6WykegKtLic/SLLRKCYamgI/AAAAAAAAAAo/30HH_MyYk0s/s1600-h/screen.JPG" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5238479286953482754" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_6WykegKtLic/SLLRKCYamgI/AAAAAAAAAAo/30HH_MyYk0s/s320/screen.JPG" border="0" alt="" /></a></p>
<p>first of all you need to add one important line of code to the top of your ASP page, that line is:</p>
<p><strong>&lt;%Response.Buffer = True%&gt;</strong></p>
<p>This line tells the server not to send anything to the client until the page is finished processing or you use &#8220;Response.Flush&#8221; code in part of your ASP page to send everything fully loaded so far.</p>
<p>now just add the following to javascript functions to your code between &#8220;script&#8221; tags, those functions are used to &#8220;show&#8221; and &#8220;hide&#8221; the splash screen when needed:</p>
<pre><code>

function showObj(obj){obj.style.visibility = "visible";}

function hideObj(obj)

{obj.style.visibility = "hidden";}</code></pre>
<p>now after we created the functions we create the part that gonna show as &#8220;splash&#8221; screen, i created it as &#8220;div&#8221; as it can contain more then one element inside it not just an animated image or text..</p>
<pre><code>  &lt;div id="splashScreen" style="position:absolute;z-index:5;align:center;"&gt;           Searching, please wait .. &lt;br&gt;          &lt;img src="loada.gif"/&gt;

  &lt;/div&gt;

</code></pre>
<p>its strongly recommended to put this div as close as possible to the nearest element after you invoke a &#8220;search&#8221; button or a &#8220;submit&#8221; button so the div would show as soon as the &#8220;fetching&#8221; face starts</p>
<p>you can put any animated &#8220;gif&#8221; pic in the img src, i choose to put a loading indicator, you can find a very nice collection of activity indicators from http://www.ajaxload.info/</p>
<p>after you put the div in the right position, you should put the &#8220;Response.Flush&#8221; code so you tell the browser to show to the user everything loaded so far &#8220;including the splash screen&#8221; and then do the processing, code executing and searching. after that you do &#8220;Response.Flush&#8221; again to show the information fetched, and finally you hide the &#8220;splash screen&#8221; .. so to make it simple, your code would be like the following:</p>
<pre><code>&lt;%..Response.Flush  'this will show everything loaded so far including the splash screen.'... put the searching/fetching code here and show the results ...'... remember that your results wont show until you flush again ....Response.Flush  'this will show everything so far including splash screen AND results

%&gt;</code></pre>
<p>and after we finished from everything we hide the &#8220;splash&#8221; screen with the following command (put the command in javascript script tag)</p>
<pre><code>var splashsplash = document.getElementById("splashScreen");hideObj(splash);</code></pre>
<p>remember that you can customize the splash to your liking, after all its a div and can be pretty flexible.</p>
<div class="blogger-post-footer">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
omandev.net English feed</div>


<p>Related posts:<ol><li><a href='http://www.omandev.net/2008/08/increasing-performance-and-adding-flexibility-using-arrays-instead-of-recordsets-in-asp-with-databases/' rel='bookmark' title='Permanent Link: Increasing performance and adding flexibility using arrays instead of recordsets in ASP with databases'>Increasing performance and adding flexibility using arrays instead of recordsets in ASP with databases</a></li>
<li><a href='http://www.omandev.net/2008/08/calling-asp-functions-from-java-script/' rel='bookmark' title='Permanent Link: Calling ASP Functions from java script'>Calling ASP Functions from java script</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.omandev.net/2008/08/adding-a-friendly-splash-waiting-screen-while-the-code-is-being-executed-in-asp/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Increasing performance and adding flexibility using arrays instead of recordsets in ASP with databases</title>
		<link>http://www.omandev.net/2008/08/increasing-performance-and-adding-flexibility-using-arrays-instead-of-recordsets-in-asp-with-databases/</link>
		<comments>http://www.omandev.net/2008/08/increasing-performance-and-adding-flexibility-using-arrays-instead-of-recordsets-in-asp-with-databases/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 13:24:00 +0000</pubDate>
		<dc:creator>Arkan Hadi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[ADO]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[recordset]]></category>
		<category><![CDATA[rs]]></category>
		<category><![CDATA[server-side]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://66.147.242.194/~omandevn/wrd1/wordpress/?p=36</guid>
		<description><![CDATA[
  

Those days, inorder to increase the websites/intranets features and interactivity it is essential to have a connectivity to a database wither its an oracle database or MS access or other types of databases, .. and with databases comes the issue of performance, so in this article i would like to share some of [...]


Related posts:<ol><li><a href='http://www.omandev.net/2008/08/adding-a-friendly-splash-waiting-screen-while-the-code-is-being-executed-in-asp/' rel='bookmark' title='Permanent Link: Adding a friendly splash (waiting screen) while the code is being executed in ASP'>Adding a friendly splash (waiting screen) while the code is being executed in ASP</a></li>
<li><a href='http://www.omandev.net/2007/07/sqltip1-search-database-faster-without-like/' rel='bookmark' title='Permanent Link: SQLTip1: search database faster without like'>SQLTip1: search database faster without like</a></li>
<li><a href='http://www.omandev.net/2010/03/exchange-2010-dag-problem/' rel='bookmark' title='Permanent Link: Exchange 2010 DAG problem?'>Exchange 2010 DAG problem?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cuser%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml>  <w:worddocument>   <w:view>Normal</w:View>   <w:zoom>0</w:Zoom>   <w:punctuationkerning/>   <w:validateagainstschemas/>   <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid>   <w:ignoremixedcontent>false</w:IgnoreMixedContent>   <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText>   <w:compatibility>    <w:breakwrappedtables/>    <w:snaptogridincell/>    <w:wraptextwithpunct/>    <w:useasianbreakrules/>    <w:dontgrowautofit/>   </w:Compatibility>   <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel>  </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml>  <w:latentstyles deflockedstate="false" latentstylecount="156">  </w:LatentStyles> </xml><![endif]--><br />
<style> <!--  /* Font Definitions */  @font-face 	{font-family:serif; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-alt:"Times New Roman"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:0 0 0 0 0 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:4.3pt; 	mso-pagination:none; 	mso-hyphenate:none; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:#00FF;} p.MsoBodyText, li.MsoBodyText, div.MsoBodyText 	{margin-top:4.3pt; 	margin-right:4.3pt; 	margin-bottom:6.0pt; 	margin-left:4.3pt; 	mso-pagination:none; 	mso-hyphenate:none; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:#00FF;} p.TableContents, li.TableContents, div.TableContents 	{mso-style-name:"Table Contents"; 	mso-style-parent:"Body Text"; 	margin:0cm; 	margin-bottom:.0001pt; 	mso-pagination:none; 	mso-hyphenate:none; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:#00FF;} @page Section1 	{size:612.0pt 792.0pt; 	margin:1.0cm 1.0cm 1.0cm 2.0cm; 	mso-header-margin:1.0cm; 	mso-footer-margin:1.0cm; 	mso-paper-source:0;} div.Section1 	{page:Section1; 	mso-footnote-position:beneath-text;} --> </style>
<p><!--[if gte mso 10]><br />
<style>  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin:0cm; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} </style>
<p> <![endif]-->
<p class="MsoNormal" style="margin: 0cm 0cm 12pt;"><span style="">Those days</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >, inord</span><span style="">er to increase the websites/intranets features and interactivity it is essential to have a connectivity to a database wither its an oracle database or MS access or other types of databases, .. and with databases comes the issue of performance, so in this article i would like to share some of the things that a developer can do t</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >o maint</span><span style="">ain a reasonable performance and even adding mor</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >e flexibil</span><span style="">ity to the ASP code dealing with databases that has huge data that needs to be fetched.</p>
<p>in this article am usin</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >g vbscri</span><span style="">pt as a server-side script.</p>
<p>for convenience i will show the steps on how to connect to MS access database first and after that i will start on the tweaks that developers can do in the coding to enhance performance and adding flexibility <o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style=";font-family:&quot;;font-size:10;"  ><% <o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style=";font-family:&quot;;font-size:10;"  >dim conn<br />
<br />set conn=Server.CreateObject(&#8220;ADODB.Connection&#8221;)<br />
<br />conn.Provider=&#8221;Microsoft.Jet.OLEDB.4.0&#8243;<br />
<br />conn.Open &#8220;c:YOUR_DATABASENAME.mdb&#8221; <o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style=";font-family:&quot;;font-size:10;"  >%><o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><span style=""><br />
<br />first of all, after you set up </span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >a connectivity</span><span style=""> to th</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >e databa</span><span style="">se, you create a query, for example:</p>
<p><b><% <o:p></o:p></b></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style="">dim rs &#8216;recored set <o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style=";font-family:&quot;;font-size:10;"  >set rs=Server.CreateObject(&#8220;ADODB.recordset&#8221;)<br />
<br />rs.Open &#8220;Select * from TABLE_NAME&#8221;, conn<o:p></o:p></span></b></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">%></span></b><span style=""></p>
<p>at this point not much can be done, connecting to the database and querying to get data is pretty much fixed.</span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><span style="">the thing start when manipulating the data we just fetched, most of the people do is manipulating the data like the following code</p>
<p><b><% <o:p></o:p></b></span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">do while not rs.EOF<br />
<br />&#8216; manipulate data here, go through the query exucuted, movenext, movelast move previous, etc</p>
<p>response.write(rs(&#8220;FIELD_NAME&#8221;))<br />
<br />rs.MoveNext<br />
<br />loop<br />
<br />rs.Close<br />
<br />conn.Close<br />
<br />set rs=nothing<br />
<br />set conn=nothing<o:p></o:p></span></b></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style=""><span style=""> </span>%><br />
<br /></span></b><span style=""></p>
<p>the above code would work perfectly if you have to deal with one query, relatively small data set in the query,  and only small code is used to manipulate the recordset, and as long as you want to deal with the data (in the above code) th</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >e records</span><span style="">et should stay open</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" ></span><span style=""> .. what if we wanted to do a new query while we are dealing with the existing one while it is still not closed? .. we would have to create another record set and set it and open connection to it, and this would make a nightmare interms of performance if we have a larg data and multiple quieries to deal with. to avoid this we can copy the query information to a multi-dimensional array and close th</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >e records</span><span style="">et so we can use it again while we are working with the existing data. instead of doing the previous code we can do the following code:</p>
<p><b><% <o:p></o:p></b></span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">dim rsArray</p>
<p>rsArray=rs.getrows()<br />
<br />rs.close<br />
<br />for i=0 to UBound(rsArray,2)-1<br />
<br />&#8216; &#8230;. work with the data here using a multi-dim array, its easier and faster, we can even<br />
<br />&#8216;use another query with the same recordset, ..<br />
<br />&#8216; we can work with the old data and with the new query data without creating new record set</p>
<p>next<br />
<br />conn.Close<br />
<br />set rs=nothing<br />
<br />set conn=nothing <o:p></o:p></span></b></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">%></span></b><span style=""></p>
<p>after we fetched the information we needed into &#8220;rsArray&#8221; we finished from the record set and we closed it &#8220;rs.close&#8221; so we can use it later while dealing with the existing data without having to create a new recordset. now while we have </span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >a multi dimensio</span><span style="">nal array in our hand, we can take advantage of that to ou</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >r bene</span><span style="">fit, even we ca</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >n red</span><span style="">im it if we want to add ne</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >w colum</span><span style="">ns or rows, but whe</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >n redim-i</span><span style="">ng the data is lost, so we have to use &#8220;preserve&#8221; keyword to preserve the data after rediming, for example if we have number of rows and we want to add a new one we do the following code<br />
<br /><b><br />
<br /><%</b></span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;">.</p>
<p class="TableContents" style="margin-bottom: 0.75pt;">.</p>
<p class="TableContents" style="margin-bottom: 0.75pt;">.<br />
<br /><span style=""><b><o:p></o:p></b></span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">dim cols</p>
<p>dim rows</p>
<p>cols = UBound(rsArray,1) +1</p>
<p>rows = UBound(rsArray,2) +1</p>
<p>redim preserve rsArray(cols,rows+1)  &#8216; we have extra row<br />
<br />%><br />
<br /></span></b><span style=""></p>
<p>notice the preserve keyword only works whe</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >n redim-i</span><span style="">ng the las</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >t dimension</span><span style="">, if we want to redim the first one (or the second one or third if we have more then 2) we have to go around it, copying the array to another array and put the dimension we want to change in the last place, and then we can use the &#8220;redim preserve&#8221; and work with the temp. array.</p>
<p>As a conclusion, </span><span style="">using the actual record sets while manipulating data and creating new ones whenever we need is not efficient, on the other hand </span><span style="">knowing the features of the arrays we can use it to our advantage so dealing with arrays is more flexible and more efficient then the actual record set.</span><span style="font-family:Arial;"><o:p></o:p></span></p>
<div class="blogger-post-footer">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
omandev.net English feed</div>


<p>Related posts:<ol><li><a href='http://www.omandev.net/2008/08/adding-a-friendly-splash-waiting-screen-while-the-code-is-being-executed-in-asp/' rel='bookmark' title='Permanent Link: Adding a friendly splash (waiting screen) while the code is being executed in ASP'>Adding a friendly splash (waiting screen) while the code is being executed in ASP</a></li>
<li><a href='http://www.omandev.net/2007/07/sqltip1-search-database-faster-without-like/' rel='bookmark' title='Permanent Link: SQLTip1: search database faster without like'>SQLTip1: search database faster without like</a></li>
<li><a href='http://www.omandev.net/2010/03/exchange-2010-dag-problem/' rel='bookmark' title='Permanent Link: Exchange 2010 DAG problem?'>Exchange 2010 DAG problem?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.omandev.net/2008/08/increasing-performance-and-adding-flexibility-using-arrays-instead-of-recordsets-in-asp-with-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
