<?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>Installation Developer &#187; SQL Server Version Detection in InstallShield</title>
	<atom:link href="http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.installationdeveloper.com</link>
	<description>InstallShield Training - InstallShield Tutorials</description>
	<lastBuildDate>Thu, 26 Jan 2012 22:12:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>SQL Server Version Detection in InstallShield</title>
		<link>http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/</link>
		<comments>http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 18:53:45 +0000</pubDate>
		<dc:creator>Rod_Maupin</dc:creator>
				<category><![CDATA[InstallShield Training]]></category>
		<category><![CDATA[installshield class]]></category>
		<category><![CDATA[installshield course]]></category>
		<category><![CDATA[installshield courses]]></category>
		<category><![CDATA[installshield programmer]]></category>
		<category><![CDATA[Installshield Tutorial]]></category>
		<category><![CDATA[installshield tutorials]]></category>

		<guid isPermaLink="false">http://www.installationdeveloper.com/?p=618</guid>
		<description><![CDATA[InstallShield has many built-in functions to use with SQL Server and a SQL Scripts view where you can create connections and configure many properties for those connections. The dialogs and functions that are provided allow you to log in, connect to a database, list all the installed instances, list all the databases, and do other [...]]]></description>
			<content:encoded><![CDATA[<p><strong>InstallShield</strong> has many built-in functions to use with <strong>SQL Server</strong> and a <strong>SQL Scripts</strong> view where you can create connections and configure many properties for those connections.</p>
<p>The dialogs and functions that are provided allow you to log in, connect to a database, list all the installed instances, list all the databases, and do other things.  They are all very helpful, but what if none of them satisfies your requirement?</p>
<p>I&#8217;m specifically talking about <strong>SQL Server</strong> version detection.  You may have the need to know the installed versions and editions of <strong>SQL Server</strong> on a machine.  Here are some of your choices:</p>
<ol>
<li><strong>Check the Registry</strong> &#8211; Not a good choice.  The registry and registry entries can change between different version of Windows and different versions of SQL Server.  So checking the registry for certain entries is not something you can rely on.</li>
<li><strong>Borrow from Prerequisites</strong> &#8211; Another method to consider is to look at some of the SQL Server prerequisites and model a check after one of those.  Each prerequisite has a list of conditions that must be satisfied in order to run (for the install to take place).  However, this also relies partially on the registry, so we can&#8217;t use this one.</li>
<li><strong>Use WMI</strong> &#8211; WMI stands for <strong>Windows Management Instrumentation</strong>.  It&#8217;s defined as the primary management technology for Microsoft® Windows® operating systems.  This is the preferred method for determining SQL Server installed versions.  In addition, Microsoft has stated that they will support WMI going forward.</li>
</ol>
<p>To use <strong>WMI</strong> in <strong>InstallShield</strong>, you have several choices, depending on what type of project you are using.  You could write a <strong>Managed Code Custom Action</strong> in <strong>C#</strong> or <strong>VB.NET</strong> to check and report the installed SQL versions.</p>
<p>You could also create a <strong>VBScript</strong> or <strong>JScript Custom Action</strong> that will get the installed versions.  This is the method I have used and is the method I will talk about.</p>
<p>I created a <strong>VBScript Custom Action</strong> that uses <strong>WMI</strong> and gets the installed <strong>SQL Server</strong> versions and editions.  It is best to first test your <strong>VBScript</strong> outside of InstallShield.  Just run the standalone .vbs file and output some of the information to the screen.</p>
<p>Once that is working properly, place the <strong>VBScript</strong> code in the Custom Action.  To return the results to your project, you will need to use Properties.  Go to the Property Manager and define several properties to hold your results.  For example, SQL_VERSION and SQL_EDITION.  With these two properites you will be able to determine the versions and editions of SQL Server.</p>
<p>After the properties are defined, you can place the results in those properties.  You do this with the <strong>Session variable</strong>.  Here&#8217;s an example:<br />
<strong><br />
Session.Property(&#8220;SQL_VERSION&#8221;)=CStr(SQLVersion)<br />
Session.Property(&#8220;SQL_EDITION&#8221;)=CStr(SQLEdition)<br />
</strong></p>
<p>On the left side of the = sign is the Property name.  On the right side is the script variable name.  Here I am using the <strong>CStr()</strong> VBScript function which converts an expression to a string.</p>
<p>Now in the script, you could have variables set up for <strong>SQL Server 2005</strong> and <strong>SQL Server 2008</strong>.  It&#8217;s up to you.  I am just illustrating the concept here.</p>
<p>I should also mention that <strong>WMI</strong> does not work for <strong>SQL Server 2000</strong>.  So, if you have to determine SQL 2000 statistics, you will have to use another method.  You might be surprised to know that many federal, state, and local governments are still using <strong>SQL Server 2000</strong>.  They don&#8217;t look forward to changing over to a newer version.  At least that&#8217;s the case in Washington state where I live.</p>
<p>In doing research on the net, you will find some posts discouraging you from using <strong>VBScript Custom Actions</strong> with InstallShield.  If it&#8217;s a bad idea, then I did not find it to be the case in my particular example.  All the testing I have done in this particular instance bears no problems.  In other cases, it may be so.</p>
<p>I have limited experience with <strong>VBScript Custom Actions</strong>.  What I do know is that <strong>VBScript</strong> error handling is horrid.  There are no try/catch blocks like in <strong>C#</strong>.  I do not use <strong>JScript</strong>, so it may be a better choice.  Perhaps using managed code custom actions is the best choice.  I am just relating what I did in one situation when I needed something done quickly.</p>
<p>If you know another way to do SQL Version checking in InstallShield, I would appreciate it if you would leave a comment so everyone will know.</p>
<p>
&nbsp;</p>
<!-- Start Sociable --><div class="sociable"><div class="sociable_tagline"><a class='sociable_tagline' target='_blank' href='http://blogplay.com' style='color:#333333;text-decoration:none'>Be Sociable, Share!</a></div><ul class='clearfix'><li><a title="Twitter" class="option1_32" style="background-position:-288px -32px" rel="nofollow" target="_blank" href="http://twitter.com/intent/tweet?text=SQL%20Server%20Version%20Detection%20in%20InstallShield%20-%20http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F%20(via%20@sociablesite)"></a></li><li><a title="Facebook" class="option1_32" style="background-position:-96px 0px" rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;t=SQL%20Server%20Version%20Detection%20in%20InstallShield"></a></li><li><a title="email" class="option1_32" style="background-position:-160px 0px" rel="nofollow" target="_blank" href="https://mail.google.com/mail/?view=cm&fs=1&to&su=SQL%20Server%20Version%20Detection%20in%20InstallShield&body=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&ui=2&tf=1&shva=1"></a></li><li><a class="option1_32" style="cursor:pointer;background-position:-128px 0px" rel="nofollow" title="Add to favorites - doesn't work in Chrome"  onClick="javascript:AddToFavorites();"></a></li><li><a title="StumbleUpon" class="option1_32" style="background-position:-224px -32px" rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&title=SQL%20Server%20Version%20Detection%20in%20InstallShield"></a></li><li><a title="Delicious" class="option1_32" style="background-position:-32px 0px" rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;title=SQL%20Server%20Version%20Detection%20in%20InstallShield&amp;notes=InstallShield%20has%20many%20built-in%20functions%20to%20use%20with%20SQL%20Server%20and%20a%20SQL%20Scripts%20view%20where%20you%20can%20create%20connections%20and%20configure%20many%20properties%20for%20those%20connections.%0D%0A%0D%0AThe%20dialogs%20and%20functions%20that%20are%20provided%20allow%20you%20to%20log%20in%2C%20connect%20"></a></li><li><a title="Google Reader" class="option1_32" style="background-position:-224px 0px" rel="nofollow" target="_blank" href="http://www.google.com/reader/link?url=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;title=SQL%20Server%20Version%20Detection%20in%20InstallShield&amp;srcURL=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;srcTitle=Installation+Developer+InstallShield+Training+-+InstallShield+Tutorials"></a></li><li><a title="LinkedIn" class="option1_32" style="background-position:-288px 0px" rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;title=SQL%20Server%20Version%20Detection%20in%20InstallShield&amp;source=Installation+Developer+InstallShield+Training+-+InstallShield+Tutorials&amp;summary=InstallShield%20has%20many%20built-in%20functions%20to%20use%20with%20SQL%20Server%20and%20a%20SQL%20Scripts%20view%20where%20you%20can%20create%20connections%20and%20configure%20many%20properties%20for%20those%20connections.%0D%0A%0D%0AThe%20dialogs%20and%20functions%20that%20are%20provided%20allow%20you%20to%20log%20in%2C%20connect%20"></a></li><li><a title="BlinkList" class="option1_32" style="background-position:0px 0px" rel="nofollow" target="_blank" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;Title=SQL%20Server%20Version%20Detection%20in%20InstallShield"></a></li><li><a style="cursor:pointer" rel="nofollow" onMouseOut="fixOnMouseOut(document.getElementById('sociable-post-618'), event, 'post-618')" onMouseOver="more(this,'post-618')"><img style='margin-top:9px' src='http://www.installationdeveloper.com/wp-content/plugins/sociable/images/more.png'></a></li></ul><div onMouseout="fixOnMouseOut(this,event,'post-618')" id="sociable-post-618" style="display:none;">   

    <div style="top: auto; left: auto; display: block;" id="sociable">



		<div class="popup">

			<div class="content">

				<ul><li style="heigth:32px;width:32px"><a title="Myspace" class="option1_32" style="background-position:0px -32px" rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;t=SQL%20Server%20Version%20Detection%20in%20InstallShield"></a></li><li style="heigth:32px;width:32px"><a title="Digg" class="option1_32" style="background-position:-64px 0px" rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;title=SQL%20Server%20Version%20Detection%20in%20InstallShield&amp;bodytext=InstallShield%20has%20many%20built-in%20functions%20to%20use%20with%20SQL%20Server%20and%20a%20SQL%20Scripts%20view%20where%20you%20can%20create%20connections%20and%20configure%20many%20properties%20for%20those%20connections.%0D%0A%0D%0AThe%20dialogs%20and%20functions%20that%20are%20provided%20allow%20you%20to%20log%20in%2C%20connect%20"></a></li><li style="heigth:32px;width:32px"><a title="Reddit" class="option1_32" style="background-position:-128px -32px" rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;title=SQL%20Server%20Version%20Detection%20in%20InstallShield"></a></li><li style="heigth:32px;width:32px"><a title="Google Bookmarks" class="option1_32" style="background-position:-192px 0px" rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;title=SQL%20Server%20Version%20Detection%20in%20InstallShield&amp;annotation=InstallShield%20has%20many%20built-in%20functions%20to%20use%20with%20SQL%20Server%20and%20a%20SQL%20Scripts%20view%20where%20you%20can%20create%20connections%20and%20configure%20many%20properties%20for%20those%20connections.%0D%0A%0D%0AThe%20dialogs%20and%20functions%20that%20are%20provided%20allow%20you%20to%20log%20in%2C%20connect%20"></a></li><li style="heigth:32px;width:32px"><a title="HackerNews" class="option1_32" style="background-position:-256px 0px" rel="nofollow" target="_blank" href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;t=SQL%20Server%20Version%20Detection%20in%20InstallShield"></a></li><li style="heigth:32px;width:32px"><a title="MSNReporter" class="option1_32" style="background-position:-352px 0px" rel="nofollow" target="_blank" href="http://reporter.es.msn.com/?fn=contribute&amp;Title=SQL%20Server%20Version%20Detection%20in%20InstallShield&amp;URL=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;cat_id=6&amp;tag_id=31&amp;Remark=InstallShield%20has%20many%20built-in%20functions%20to%20use%20with%20SQL%20Server%20and%20a%20SQL%20Scripts%20view%20where%20you%20can%20create%20connections%20and%20configure%20many%20properties%20for%20those%20connections.%0D%0A%0D%0AThe%20dialogs%20and%20functions%20that%20are%20provided%20allow%20you%20to%20log%20in%2C%20connect%20"></a></li><li style="heigth:32px;width:32px"><a title="Sphinn" class="option1_32" style="background-position:-192px -32px" rel="nofollow" target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F"></a></li><li style="heigth:32px;width:32px"><a title="Posterous" class="option1_32" style="background-position:-64px -32px" rel="nofollow" target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;title=SQL%20Server%20Version%20Detection%20in%20InstallShield&amp;selection=InstallShield%20has%20many%20built-in%20functions%20to%20use%20with%20SQL%20Server%20and%20a%20SQL%20Scripts%20view%20where%20you%20can%20create%20connections%20and%20configure%20many%20properties%20for%20those%20connections.%0D%0A%0D%0AThe%20dialogs%20and%20functions%20that%20are%20provided%20allow%20you%20to%20log%20in%2C%20connect%20"></a></li><li style="heigth:32px;width:32px"><a title="Tumblr" class="option1_32" style="background-position:-256px -32px" rel="nofollow" target="_blank" href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;t=SQL%20Server%20Version%20Detection%20in%20InstallShield&amp;s=InstallShield%20has%20many%20built-in%20functions%20to%20use%20with%20SQL%20Server%20and%20a%20SQL%20Scripts%20view%20where%20you%20can%20create%20connections%20and%20configure%20many%20properties%20for%20those%20connections.%0D%0A%0D%0AThe%20dialogs%20and%20functions%20that%20are%20provided%20allow%20you%20to%20log%20in%2C%20connect%20"></a></li></ul>			

			</div>        

		  <a style="cursor:pointer" onclick="hide_sociable('post-618',true)" class="close">



		  <img onclick="hide_sociable('post-618',true)" title="close" src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/closelabel.png">

		  </a>

		</div>

	</div> 

  </div></div><div class='sociable' style='float:none'><ul class='clearfix'><li id="Twitter_Counter"><a href="https://twitter.com/share" data-text="SQL Server Version Detection in InstallShield - http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/ (via #sociablesite)" data-url="http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></li><li id="Facebook_Counter"><iframe src="//www.facebook.com/plugins/like.php?href=http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/&send=false&layout=button_count&show_faces=false&action=like&colorscheme=light&font" scrolling="no" frameborder="0" style="border:none; overflow:hidden;height:32px;width:100px" allowTransparency="true"></iframe></li><li id="Google_+"><g:plusone annotation="bubble" href="http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/" size="medium"></g:plusone></li><li id="LinkedIn_Counter"><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-url="http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/" data-counter="right"></script></li><li id="StumbleUpon_Counter"><script src="http://www.stumbleupon.com/hostedbadge.php?s=2&r=http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/"></script></li></ul></div><!-- End Sociable -->]]></content:encoded>
			<wfw:commentRss>http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

