<?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>Tue, 27 Jul 2010 14:57:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<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 things. [...]]]></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>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a 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" title="Digg"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a 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" title="del.icio.us"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a 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" title="Facebook"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;h=SQL%20Server%20Version%20Detection%20in%20InstallShield" title="NewsVine"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a 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" title="Reddit"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a 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&amp;title=SQL%20Server%20Version%20Detection%20in%20InstallShield" title="StumbleUpon"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a 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" title="Google Bookmarks"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;submitHeadline=SQL%20Server%20Version%20Detection%20in%20InstallShield&amp;submitSummary=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&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=SQL%20Server%20Version%20Detection%20in%20InstallShield%20-%20http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F" title="Twitter"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F" title="Technorati"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.installationdeveloper.com%2F618%2Fsql-server-version-detection-in-installshield%2F&amp;title=SQL%20Server%20Version%20Detection%20in%20InstallShield" title="Live"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a 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" title="LinkedIn"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a 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" title="MySpace"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></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>
