<?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>super-cooper &#187; sqlserver</title>
	<atom:link href="http://www.super-cooper.com/archive/tag/sqlserver/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.super-cooper.com</link>
	<description>Python, GIS, and a sprinkling of mindless drivel from Chad Cooper</description>
	<lastBuildDate>Wed, 08 Dec 2010 02:12:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Executing a SQL Server stored procedure in C#</title>
		<link>http://www.super-cooper.com/archive/2008/08/16/executing-a-sql-server-stored-procedure-in-c/</link>
		<comments>http://www.super-cooper.com/archive/2008/08/16/executing-a-sql-server-stored-procedure-in-c/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 21:13:59 +0000</pubDate>
		<dc:creator>Chad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[sqlserver]]></category>

		<guid isPermaLink="false">http://www.super-cooper.com/?p=60</guid>
		<description><![CDATA[Are you kidding me? I&#8217;m a major amatuer at anything .NET, and after some Googling and about 15 minutes of coding, this works. How ridiculously easy. using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; &#160; namespace ExecuteStoredProcedure &#123; class Program &#123; static void Main&#40;string&#91;&#93; args&#41; &#123; SqlConnection conn; try &#123; conn = new [...]]]></description>
			<content:encoded><![CDATA[<p>Are you kidding me? I&#8217;m a major amatuer at anything .NET, and after some Googling and about 15 minutes of coding, this works. How ridiculously easy.</p>
<link rel="stylesheet" href="http://www.super-cooper.com/wp-content/plugins/codeviewer.css" type="text/css" media="all" />
<ol class="codelist">
<li value="1" class="tab0 odd"><code><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;</code></li>
<li value="2" class="tab0 even"><code><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>.<span style="color: #0000FF;">Generic</span>;</code></li>
<li value="3" class="tab0 odd"><code><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Text</span>;</code></li>
<li value="4" class="tab0 even"><code><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Data</span>;</code></li>
<li value="5" class="tab0 odd"><code><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Data</span>.<span style="color: #0000FF;">SqlClient</span>;</code></li>
<li value="6" class="even">&nbsp;</li>
<li value="7" class="tab0 odd"><code><span style="color: #0600FF;">namespace</span> ExecuteStoredProcedure</code></li>
<li value="8" class="tab0 even"><code><span style="color: #000000;">&#123;</span></code></li>
<li value="9" class="tab1 odd"><code><span style="color: #FF0000;">class</span> Program</code></li>
<li value="10" class="tab1 even"><code><span style="color: #000000;">&#123;</span></code></li>
<li value="11" class="tab2 odd"><code><span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span></code></li>
<li value="12" class="tab2 even"><code><span style="color: #000000;">&#123;</span></code></li>
<li value="13" class="tab3 odd"><code>SqlConnection conn;</code></li>
<li value="14" class="tab3 even"><code><span style="color: #0600FF;">try</span></code></li>
<li value="15" class="tab3 odd"><code><span style="color: #000000;">&#123;</span></code></li>
<li value="16" class="tab4 even"><code>conn <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SqlConnection<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;server=server;database=db;Trusted_Connection=yes&quot;</span><span style="color: #000000;">&#41;</span>;</code></li>
<li value="17" class="tab4 odd"><code>conn.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</code></li>
<li value="18" class="tab4 even"><code>Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Connection successful...&quot;</span><span style="color: #000000;">&#41;</span>;</code></li>
<li value="19" class="tab3 odd"><code><span style="color: #000000;">&#125;</span></code></li>
<li value="20" class="tab3 even"><code><span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception ex<span style="color: #000000;">&#41;</span></code></li>
<li value="21" class="tab3 odd"><code><span style="color: #000000;">&#123;</span></code></li>
<li value="22" class="tab4 even"><code>Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span>ex.<span style="color: #0000FF;">Message</span><span style="color: #000000;">&#41;</span>;</code></li>
<li value="23" class="tab4 odd"><code><span style="color: #0600FF;">return</span>;</code></li>
<li value="24" class="tab3 even"><code><span style="color: #000000;">&#125;</span></code></li>
<li value="25" class="odd">&nbsp;</li>
<li value="26" class="tab3 even"><code>SqlCommand db_cmd <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SqlCommand<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;dbo.usp_c_sharp_test&quot;</span>,conn<span style="color: #000000;">&#41;</span>;</code></li>
<li value="27" class="tab3 odd"><code>db_cmd.<span style="color: #0000FF;">CommandType</span> <span style="color: #008000;">=</span> CommandType.<span style="color: #0000FF;">StoredProcedure</span>;</code></li>
<li value="28" class="even">&nbsp;</li>
<li value="29" class="tab3 odd"><code>SqlDataReader data_reader;</code></li>
<li value="30" class="tab3 even"><code>data_reader <span style="color: #008000;">=</span> db_cmd.<span style="color: #0000FF;">ExecuteReader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</code></li>
<li value="31" class="tab3 odd"><code>data_reader.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</code></li>
<li value="32" class="tab3 even"><code>conn.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</code></li>
<li value="33" class="tab2 odd"><code><span style="color: #000000;">&#125;</span></code></li>
<li value="34" class="tab1 even"><code><span style="color: #000000;">&#125;</span></code></li>
<li value="35" class="tab0 odd"><code><span style="color: #000000;">&#125;</span></code></li>
<li class="sourcelink"><strong>Download this code:</strong> <a href="http://www.super-cooper.com/snippets/execute-stored-procedure.cs">execute-stored-procedure.cs</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.super-cooper.com/archive/2008/08/16/executing-a-sql-server-stored-procedure-in-c/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

