<?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>GonsWorld &#187; Red Gate</title>
	<atom:link href="http://www.gonsworld.com/category/information-tech/red-gate/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gonsworld.com</link>
	<description>News and Views from the Head of Gon!</description>
	<lastBuildDate>Sat, 05 Dec 2009 02:37:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Executing your own SQL queries together with SDK synchronization</title>
		<link>http://www.gonsworld.com/executing-your-own-sql-queries-together-with-sdk-synchronization/</link>
		<comments>http://www.gonsworld.com/executing-your-own-sql-queries-together-with-sdk-synchronization/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 15:55:37 +0000</pubDate>
		<dc:creator>Gon</dc:creator>
				<category><![CDATA[Red Gate]]></category>

		<guid isPermaLink="false">http://www.gonsworld.com/?p=488</guid>
		<description><![CDATA[<p>Taken from:</p>
<p>http://www.red-gate.com/supportcenter/Content.aspx?p=SQL%20Comparison%20SDK&#038;c=knowledgebaseSQL_Comparison_SDKKB200809000297.htm</p>
<p class="tcbodytext">Category: SDK, API &#38; Command line
Date: 15 May 2009
Product: SQL Comparison SDK
When executing a synchronization script created by the SQL Comparison SDK, it may be desired that some ad-hoc queries be intermixed with the SQL produced by the Red Gate APIs.</p>
<p class="tcbodytext">Because the BlockExecutor class can only run SQL code by converting ExecutionBlocks [...]]]></description>
			<content:encoded><![CDATA[<p>Taken from:</p>
<p>http://www.red-gate.com/supportcenter/Content.aspx?p=SQL%20Comparison%20SDK&#038;c=knowledgebaseSQL_Comparison_SDKKB200809000297.htm</p>
<p class="tcbodytext">Category: SDK, API &amp; Command line<br />
Date: 15 May 2009<br />
Product: SQL Comparison SDK<br />
When executing a synchronization script created by the SQL Comparison SDK, it may be desired that some ad-hoc queries be intermixed with the SQL produced by the Red Gate APIs.</p>
<p class="tcbodytext">Because the BlockExecutor class can only run SQL code by converting ExecutionBlocks to SQL code and submitting them to the SQL Server, custom SQL cannot be introduced into the query stream. It is possible, however, to break an ExecutionBlock into individual query batches and running them using the .NET Framework&#8217;s ADO .NET methods.</p>
<p>In the following C# example, a SQL query &#8220;SET LANGUAGE us_english&#8221; needs to be submitted before the synchronization produced by the SQL Data Compare Engine. First, a connection is made to the server using the connection properties of the second database. Then a transaction is created. The custom SQL query is run first, then each batch of SQL from the ExecutionBlock in order. Finally, the transaction is committed. If any errors occur during the execution of the SQL script, then the error is written to the console and the transaction will be rolled back.</p>
<p>ExecutionBlock block = provider.GetMigrationSQL(session, new SelectionDelegate(this.SyncRecord), true);</p>
<p>&#8230;</p>
<p>System.Data.SqlClient.SqlTransaction trans = null;<br />
try<br />
{<br />
// Make a connection string from the second database connection properties<br />
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(&#8220;Data Source=&#8221;+db2.ConnectionProperties.ServerName+&#8221;;Initial Catalog=&#8221;+db2.ConnectionProperties.DatabaseName+&#8221;;Integrated Security=SSPI&#8221;);<br />
System.Data.SqlClient.SqlCommand cmd = conn.CreateCommand();<br />
conn.Open();<br />
trans = conn.BeginTransaction(&#8220;MyTransaction&#8221;);<br />
//Run the first command<br />
cmd.Transaction = trans;<br />
cmd.CommandText = &#8220;SET LANGUAGE us_english&#8221;;<br />
cmd.ExecuteNonQuery();<br />
//Run batches<br />
for (int i = 0; i &lt; block.BatchCount; i++)<br />
{<br />
Batch b = block.GetBatch(i);<br />
if (!b.Marker)<br />
{<br />
cmd.CommandText = b.Contents;<br />
cmd.ExecuteNonQuery();<br />
}<br />
}<br />
trans.Commit();<br />
}<br />
catch (System.Data.SqlClient.SqlException se)<br />
{<br />
Console.WriteLine(&#8220;Execute SQL failed: &#8221; + se.Message);<br />
trans.Rollback();<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gonsworld.com/executing-your-own-sql-queries-together-with-sdk-synchronization/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Welcome to my Red Gate Eval Center!</title>
		<link>http://www.gonsworld.com/welcome-to-my-red-gate-eval-center/</link>
		<comments>http://www.gonsworld.com/welcome-to-my-red-gate-eval-center/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 15:53:02 +0000</pubDate>
		<dc:creator>Gon</dc:creator>
				<category><![CDATA[Red Gate]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://www.gonsworld.com/?p=485</guid>
		<description><![CDATA[<p>I&#8217;ve been working with some really great software lately, and need to keep my own Knowledge Base for critical issues.</p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with some really great software lately, and need to keep my own Knowledge Base for critical issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gonsworld.com/welcome-to-my-red-gate-eval-center/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

