<?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>bobpeers -&#62; blog &#187; ado</title>
	<atom:link href="http://blog.bobpeers.com/tag/ado/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bobpeers.com</link>
	<description>Better late than never</description>
	<lastBuildDate>Fri, 24 Jun 2011 12:34:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using ADO With JavaScript</title>
		<link>http://blog.bobpeers.com/2008/04/06/using-ado-with-javascript/</link>
		<comments>http://blog.bobpeers.com/2008/04/06/using-ado-with-javascript/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 20:08:53 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[ado]]></category>
		<category><![CDATA[hta]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/04/06/using-ado-with-javascript/</guid>
		<description><![CDATA[When writing HTAs to connect to an MS Access database I used to always use VBScript. The obvious reason for this being that it seemed easier since both are Microsoft technologies plus I initially had no idea how to create or use ActiveXObjects from JavaScript. After doing this for a while I became very frustrated [...]]]></description>
			<content:encoded><![CDATA[<p>When writing HTAs to connect to an MS Access database I used to always use VBScript.<br />
The obvious reason for this being that it seemed easier since both are Microsoft technologies plus I initially had no idea how to create or use ActiveXObjects from JavaScript.</p>
<p>After doing this for a while I became very frustrated at the limitations of using VBScript so looked deeper into changing to JavaScript and found that&#8217;s it&#8217;s actually very easy to use.</p>
<p>As a starter for anyone else in the same position here some framework code showing how to create an ADO connection, open a recordset and execute the command object all using JavaScript.<br />
(I know technically this is <a href="http://en.wikipedia.org/wiki/JScript" title="Wikipedia JScript page">JScript</a>, which is Microsofts version of JavaScript)</p>
<pre>// path to database
var DBpath="\\\\Server\\Path\\myDB.mdb"

// set up a few object constants
var adLockReadOnly=1
var adOpenForwardOnly=0
var adCmdText=1

// create and open a new connection (MSAccess)
var cnn=new ActiveXObject("ADODB.connection")
cnn.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=" + DBpath
try
    {
    cnn.open
    }
catch(err)
    {
    // could not open connection
    // view details in err.Description and err.Number
    return 0
    }

//open a read only recordset
var rs = new ActiveXObject("ADODB.Recordset")
try
	{
	rs.Open("Select * from myTable", cnn, adOpenForwardOnly, adLockReadOnly)
	}
catch(err)
	{
	// could not open recordset
	return 0
	}
while(!rs.EOF)
	{
	// do something
	rs.movenext
	}
rs.close

//insert records with command object
var cmd=new ActiveXObject("ADODB.command")
cmd.ActiveConnection = cnn
cmd.CommandText = "Insert into myTables values(x ,y ,z)"
cmd.CommandType=adCmdText
    try
    {
    cmd.Execute()
    }
    catch(err)
    {
    // could not execute SQL
    return 0
    }
</pre>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;count=none&amp;text=Using%20ADO%20With%20JavaScript" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;count=none&amp;text=Using%20ADO%20With%20JavaScript" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;linkname=Using%20ADO%20With%20JavaScript" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;linkname=Using%20ADO%20With%20JavaScript" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;linkname=Using%20ADO%20With%20JavaScript" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;linkname=Using%20ADO%20With%20JavaScript" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;linkname=Using%20ADO%20With%20JavaScript" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;linkname=Using%20ADO%20With%20JavaScript" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;linkname=Using%20ADO%20With%20JavaScript" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;linkname=Using%20ADO%20With%20JavaScript" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fusing-ado-with-javascript%2F&amp;title=Using%20ADO%20With%20JavaScript" id="wpa2a_2"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/04/06/using-ado-with-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Prevent Security Warnings Using ADO With HTAs</title>
		<link>http://blog.bobpeers.com/2008/04/06/prevent-security-warnings-using-ado-with-htas/</link>
		<comments>http://blog.bobpeers.com/2008/04/06/prevent-security-warnings-using-ado-with-htas/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 19:22:43 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[ado]]></category>
		<category><![CDATA[hta]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/04/06/prevent-security-warnings-using-ado-with-htas/</guid>
		<description><![CDATA[If you are using the ADO object to connect to a database within an HTA in a networked environment then you will get a rather annoying message box warning about ActiveXObjects. To prevent this in all my HTAs I start the script off with the following statements (this is in Javascript). var objShell = new [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using the <a href="http://en.wikipedia.org/wiki/ActiveX_Data_Objects" title="Wikipedia ADO page">ADO object</a> to connect to a database within an <a href="http://msdn2.microsoft.com/en-us/library/ms536496(VS.85).aspx" title="MSDN HTA site">HTA</a> in a networked environment then you will get a rather annoying message box warning about ActiveXObjects.</p>
<p>To prevent this in all my HTAs I start the script off with the following statements (this is in Javascript).</p>
<pre>var objShell = new ActiveXObject("WScript.Shell")
objShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\1\\1406", 0, "REG_DWORD")
objShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\myServer\\file", 2, "REG_DWORD")
objShell=null
</pre>
<p>The effect of the first RegWrite is to allow &#8216;Access data sources across domains&#8217; and then the second write adds my network location (myServer) to the trusted sites.</p>
<p>These can be manually changed from within Internet Explorer as they are the zones settings in Internet Options.</p>
<p>Setting these keys requires no admin rights but they may well get overwritten by Group Policy so it&#8217;s best just to include them at the start of the script.</p>
<p>Note that the first time the application is run you will still get the warning as it will have read the old values, but by the next run they will be set.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;count=none&amp;text=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;count=none&amp;text=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;linkname=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;linkname=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;linkname=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;linkname=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;linkname=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;linkname=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;linkname=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;linkname=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F04%2F06%2Fprevent-security-warnings-using-ado-with-htas%2F&amp;title=Prevent%20Security%20Warnings%20Using%20ADO%20With%20HTAs" id="wpa2a_4"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/04/06/prevent-security-warnings-using-ado-with-htas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

