<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Yanachik.org &#187; Website Development</title>
	<atom:link href="http://www.yanachik.org/category/websitedevelopment/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yanachik.org</link>
	<description>IT Administration and Application Development</description>
	<lastBuildDate>Mon, 02 May 2011 12:36:02 +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>Now running on Amazon EC2</title>
		<link>http://www.yanachik.org/2011/02/18/test-post-1/</link>
		<comments>http://www.yanachik.org/2011/02/18/test-post-1/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 21:14:39 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/?p=338</guid>
		<description><![CDATA[This weekend I migrated my blog (and hosting) from a shared host to my own instance on Amazon EC2.  I am pleased with the speed-boost that I&#8217;ve received and the [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend I migrated my blog (and hosting) from a shared host to my own instance on Amazon EC2.  I am pleased with the speed-boost that I&#8217;ve received and the total control of the server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2011/02/18/test-post-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to connect a Rails app running on Ubuntu Linux to Microsoft SQL Server</title>
		<link>http://www.yanachik.org/2010/12/14/how-to-connect-a-rails-app-running-on-ubuntu-linux-to-microsoft-sql-server/</link>
		<comments>http://www.yanachik.org/2010/12/14/how-to-connect-a-rails-app-running-on-ubuntu-linux-to-microsoft-sql-server/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 19:14:39 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/?p=256</guid>
		<description><![CDATA[Taken from http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation&#8212;Ubuntu http://wiki.rubyonrails.org/database-support/ms-sql Install Unix ODBC sudo apt-get install unixodbc-dev Install Free TDS sudo apt-get install freetds-dev tdsodbc Install the Ruby ODBC Binding wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz tar -zxvf ruby-odbc-0.9997.tar.gz cd [...]]]></description>
			<content:encoded><![CDATA[<p>Taken from</p>
<ul>
<li><a href="http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation---Ubuntu">http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation&#8212;Ubuntu</a></li>
<li><a href="http://wiki.rubyonrails.org/database-support/ms-sql">http://wiki.rubyonrails.org/database-support/ms-sql</a></li>
</ul>
<h2>Install Unix ODBC</h2>
<p><code>sudo apt-get install unixodbc-dev</code></p>
<h2>Install Free TDS</h2>
<p><code>sudo apt-get install freetds-dev tdsodbc</code></p>
<h2>Install the Ruby ODBC Binding</h2>
<p><code>wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz</code></p>
<p><code>tar -zxvf ruby-odbc-0.9997.tar.gz</p>
<p>cd ruby-odbc-0.9997</p>
<p>ruby extconf.rb</p>
<p>make</p>
<p></code></p>
<p><code>sudo make install [yields:/usr/bin/install -c -m 0755 odbc.so /usr/local/lib/site_ruby/1.8/x86_64-linux]</code></p>
<h2>Install the following gems</h2>
<p><code>sudo gem install dbd-odbc</code></p>
<p><code> </code></p>
<p><code>sudo gem install dbi</code></p>
<h2>Install the Activerecord SQLServer Adapter</h2>
<p><code>sudo gem install activerecord-sqlserver-adapter</code></p>
<h2>Configure FreeTDS</h2>
<p><code>sudo nano /etc/freetds/freetds.conf</code></p>
<p><code></p>
<p style="padding-left: 30px;">[developer]</p>
<p style="padding-left: 30px;">host = testserver.local.domain (i.e. Fully Qualified DNS)</p>
<p style="padding-left: 30px;">port = 1433</p>
<p></code></p>
<p style="padding-left: 30px;"><code>tds version = 8.0</code></p>
<h2>Test FreeTDS</h2>
<p><code>sudo apt-get install sqsh</code></p>
<p><code> </code></p>
<p><code>sqsh -S developer -U database_username -P database_password</code></p>
<h2>Configure UnixODBC</h2>
<p><code>sudo nano /etc/odbcinst.ini</code></p>
<p><code></p>
<p style="padding-left: 30px;">[FreeTDS]</p>
<p style="padding-left: 30px;">Description     = TDS driver (Sybase/MS SQL)</p>
<p style="padding-left: 30px;">Driver          = /usr/lib/odbc/libtdsodbc.so</p>
<p style="padding-left: 30px;">Setup           = /usr/lib/odbc/libtdsS.so</p>
<p style="padding-left: 30px;">CPTimeout       =</p>
<p style="padding-left: 30px;">CPReuse         =</p>
<p></code></p>
<p style="padding-left: 30px;"><code>FileUsage       = 1</code></p>
<h2>Create ODBC Entries for your database</h2>
<p><code>sudo nano /etc/odbc.ini</code></p>
<p><code></p>
<p style="padding-left: 30px;">[development]</p>
<p style="padding-left: 30px;">Driver = FreeTDS</p>
<p style="padding-left: 30px;">Description     = ODBC connection via FreeTDS</p>
<p style="padding-left: 30px;">Trace           = No</p>
<p style="padding-left: 30px;">Server      = 192.168.1.2 (IP Address of SQL Server)</p>
<p></code></p>
<p style="padding-left: 30px;"><code>Database        = production</code></p>
<h2>Test UnixODBC</h2>
<p><code>isql -v development database_username password</code></p>
<p><code> </code></p>
<p><code>SQL&gt; select count(*) from people;</code></p>
<h2>Install ruby-odbc</h2>
<p>You have to download and compile the source yourself to set a specific flag</p>
<p><code>wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.99992.tar.gz</code></p>
<p><code>tar -zxvf ruby-odbc-0.99992.tar.gz</p>
<p>cd ruby-odbc-0.99992</p>
<p>ruby -Cext extconf.rb --disable-dlopen</p>
<p>make -C ext</p>
<p></code></p>
<p><code>sudo make -C ext install</code></p>
<h2>Test ruby-odbc</h2>
<p><code>irb</code></p>
<p><code>require 'odbc'</p>
<p></code></p>
<p><code>ODBC.connect("development", "username", "password")</code></p>
<h2>ActiveRecord SQL Server Adapter</h2>
<p>Install the activerecord-sqlserver-adapter version 2.3.5  (I believe there are problems with other versions)</p>
<p><code>sudo gem install activerecord-sqlserver-adapter -v=2.3.5</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2010/12/14/how-to-connect-a-rails-app-running-on-ubuntu-linux-to-microsoft-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby on Rails on Windows]]></series:name>
	</item>
		<item>
		<title>Rails 3.0 unobtrusive Ajax in Rails 2.3.x (with jQuery) &#8211; Andrew Cox</title>
		<link>http://www.yanachik.org/2010/12/03/rails-3-0-unobtrusive-ajax-in-rails-2-3-x-with-jquery-andrew-cox/</link>
		<comments>http://www.yanachik.org/2010/12/03/rails-3-0-unobtrusive-ajax-in-rails-2-3-x-with-jquery-andrew-cox/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 20:18:15 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/?p=327</guid>
		<description><![CDATA[The following instructions will get unobtrusive ajax working with jQuery in rails 2.3.x just like it is done in rails 3.x. Rails 3.0 unobtrusive Ajax in Rails 2.3.x &#8211; Andrew [...]]]></description>
			<content:encoded><![CDATA[<p>The following instructions will get unobtrusive ajax working with jQuery in rails 2.3.x just like it is done in rails 3.x.  </p>
<p><a href="http://andrewcox.org/post/507032751/rails-3-0-unobtrusive-ajax-in-rails-2-3-x">Rails 3.0 unobtrusive Ajax in Rails 2.3.x &#8211; Andrew Cox</a>.</p>
<p>I can&#8217;t wait to implement <a href="http://railscasts.com/episodes/240-search-sort-paginate-with-ajax">Search, Sort, Paginate with AJAX</a> in a rails 2.3.8 application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2010/12/03/rails-3-0-unobtrusive-ajax-in-rails-2-3-x-with-jquery-andrew-cox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The creators of no-longer-with-us products explain what went wrong</title>
		<link>http://www.yanachik.org/2010/12/03/the-creators-of-no-longer-with-us-products-explain-what-went-wrong/</link>
		<comments>http://www.yanachik.org/2010/12/03/the-creators-of-no-longer-with-us-products-explain-what-went-wrong/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 18:48:40 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/?p=323</guid>
		<description><![CDATA[From Signal vs. Noise http://37signals.com/svn/posts/2682-the-creators-of-no-longer-with-us-products-explain-what-went-wrong Wesabe launched as a site to help people manage their personal finances. While competitor Mint was acquired by Intuit, Wesabe eventually shut down. In “Why [...]]]></description>
			<content:encoded><![CDATA[<p>From Signal vs. Noise<br />
<a href="http://37signals.com/svn/posts/2682-the-creators-of-no-longer-with-us-products-explain-what-went-wrong">http://37signals.com/svn/posts/2682-the-creators-of-no-longer-with-us-products-explain-what-went-wrong<br />
</a></p>
<blockquote><p>Wesabe launched as a site to help people manage their personal finances. While competitor Mint was acquired by Intuit, Wesabe eventually shut down. In “Why Wesabe Lost to Mint,” Marc Hedlund dissects what happened.</p>
<p>“<strong>Mint focused on making the user do almost no work at all</strong>, by automatically editing and categorizing their data, reducing the number of fields in their signup form, and giving them immediate gratification as soon as they possibly could; we completely sucked at all of that…I was focused on trying to make the usability of editing data as easy and functional as it could be; <strong>Mint was focused on making it so you never had to do that at all</strong>. Their approach completely kicked our approach’s ass.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2010/12/03/the-creators-of-no-longer-with-us-products-explain-what-went-wrong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Development Environment on Windows</title>
		<link>http://www.yanachik.org/2010/11/23/rails-development-environment-on-windows/</link>
		<comments>http://www.yanachik.org/2010/11/23/rails-development-environment-on-windows/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 13:18:37 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/?p=310</guid>
		<description><![CDATA[Here&#8217;s my setup for developing Rails applications on Windows: Ruby Ruby 1.8.7 Rails Rails 2.3.8 Gem Files activerecord-sqlserver-adapter (See my previous post on working with SQL Server) ruby-odbc composite_primary_keys win32console [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s my setup for developing Rails applications on Windows:</p>
<p><strong>Ruby</strong><br />
Ruby 1.8.7</p>
<p><strong>Rails</strong><br />
Rails 2.3.8</p>
<p><strong>Gem Files</strong><br />
activerecord-sqlserver-adapter (See my previous post on working with SQL Server)<br />
ruby-odbc<br />
composite_primary_keys<br />
win32console</p>
<p><strong>Source Control</strong><br />
Git:  <a href="http://git-scm.com/">http://git-scm.com/</a></p>
<p><strong>IDE/Editor</strong><br />
Vim:  <a href="http://www.vim.org">http://www.vim.org</a></p>
<p><u>Plugins</u><br />
Download this zip file and extract the contents to c:\users\USERNAME\vimfiles<br />
<a href='http://www.yanachik.org/wp-content/uploads/2010/11/vimfiles.zip'>vimfiles.zip</a></p>
<p><u>_gvimrc</u><br />
Download this zip file and extract to c:\users\USERNAME\_gvimrc<br />
<a href='http://www.yanachik.org/wp-content/uploads/2010/11/gvimrc.zip'>_gvimrc.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2010/11/23/rails-development-environment-on-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<series:name><![CDATA[Ruby on Rails on Windows]]></series:name>
	</item>
		<item>
		<title>Composite Primary Keys in Ruby on Rails</title>
		<link>http://www.yanachik.org/2010/10/01/composite-primary-keys-in-ruby-on-rails/</link>
		<comments>http://www.yanachik.org/2010/10/01/composite-primary-keys-in-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 18:14:28 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/?p=243</guid>
		<description><![CDATA[If you&#8217;re using Microsoft SQL Server as the database server for your rails app it&#8217;s probably because you&#8217;re writing a web app for an existing database. It&#8217;s also likely that [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using Microsoft SQL Server as the database server for your rails app it&#8217;s probably because you&#8217;re writing a web app for an existing database.  It&#8217;s also likely that the database structure does not follow the rails default (ids for primary keys) and you probably have some tables with composite primary keys.</p>
<h2>Install</h2>
<p>Rails by default cannot handle composite primary keys.  <a href="http://compositekeys.rubyforge.org/">Luckily there&#8217;s a gem for that!</a> Install the &#8220;Composite Primary Keys&#8221; gem from the Command Prompt with Ruby:<br />
<code>gem install composite_primary_keys</code></p>
<h2>Configure Rails App</h2>
<p>To use the Composite Primary Keys gem in your rails app add the following to the bottom of your environment.rb file (outside of the end tag that&#8217;s there for the Rails::Initializer.run do |config|) located in the config directory of your rails app:<br />
<code>require 'composite_primary_keys'</code></p>
<p>Note:  If your server is running when you make the change to the envorinment.rb file you will receive an error such as &#8220;undefined method `set_primary_keys&#8217; for #&#8221; when viewing a page on your site using the model.  Restart your server so it re-loads the environment.rb file.</p>
<h2>Define the Composite Key in the model</h2>
<p>To define the composite key for your model use the set_primary_keys call:</p>
<p><code>class Mymodel &lt; ActiveRecord::Base</code></p>
<p style="padding-left: 30px;"><code> set_primary_keys :key1, :key2<br />
</code></p>
<p><code>end</code></p>
<h2>How to find a record with composite primary keys</h2>
<p>Instead of passing in a single id in the find method for your model: <code>find(1)</code>, pass an array of the ids matching the order that they were defined in your class: <code>find([1, 1])</code>.<br />
<code>mymodel = Mymodel.find([1, 1])</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2010/10/01/composite-primary-keys-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby on Rails on Windows]]></series:name>
	</item>
		<item>
		<title>Getting Rails to talk to MS SQL Server from a 64-bit Windows 7 computer</title>
		<link>http://www.yanachik.org/2010/10/01/getting-rails-to-talk-to-ms-sql-server-from-a-64-bit-windows-7-computer/</link>
		<comments>http://www.yanachik.org/2010/10/01/getting-rails-to-talk-to-ms-sql-server-from-a-64-bit-windows-7-computer/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 15:36:53 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/?p=184</guid>
		<description><![CDATA[The only way I&#8217;ve been able to get a Rails application to communicate with Microsoft SQL Server is through a User DSN ODBC connection. Rails cannot connect to a System [...]]]></description>
			<content:encoded><![CDATA[<p>The only way I&#8217;ve been able to get a Rails application to communicate with Microsoft SQL Server is through a User DSN ODBC connection.  Rails cannot connect to a System DSN using 64-bit Windows when in a development environment.</p>
<p>Here&#8217;s how to install the gems necessary to do this, how to setup your ODBC connection, and how to setup the database.yml file in your rails project.</p>
<h2>ActiveRecord SQL Server Adapter</h2>
<p>Install the activerecord-sqlserver-adapter version 2.3.5  (I believe there are problems with other versions)<br />
<code>gem install activerecord-sqlserver-adapter -v=2.3.5</code></p>
<h2>Development Kit</h2>
<h3>Download and Extract</h3>
<p>The ruby-odbc gem will not install without first installing the DevKit add-on from RubyInstaller.org  I downloaded DevKit-4.5.0-20100819-1536-sfx.exe from <a href="http://rubyinstaller.org/downloads/">http://rubyinstaller.org/downloads/</a> under the</p>
<h3>Development Kit</h3>
<p>heading.<br />
After downloading the file run it and let it self-extract to a folder of your choice.  (Warning, the self-extractor will not create a sub-folder in the location that you choose, so you might want to create your own subfolder first and then extract there)<br />
<strong>Install</strong></p>
<ol>
<li>Start a new Command Prompt with Ruby (Start &#8211; All Programs &#8211; Ruby187 &#8211; Start Command Prompt with Ruby) and change into the extracted DevKit directory.</li>
<li>Run:  <code>ruby dk.rb init</code></li>
<li>Run:  <code>ruby dk.rb install</code></li>
</ol>
<h2>Ruby ODBC</h2>
<p>The ruby-odbc gem must be installed for the SQL Server adapter to connect through ODBC.  From your Command Prompt with Ruby run:  <code>gem install ruby-odbc</code>.</p>
<h2>Connect a Rails app to SQL Server</h2>
<h3>Create the ODBC Connection</h3>
<ol>
<li>Open up the ODBC Data Source Administrator (Start &#8211; Control Panel &#8211; Administrative Tools &#8211; Data Sources (ODBC)</li>
<li>Select the User DSN tab</li>
<li>Click on the Add Button</li>
<li>Select SQL Server and click Finish</li>
<li>Give the data source a name that you will refer to in your rails database configuration file (DSN_NAME)</li>
<li>Select the server to connect to</li>
<li>Click Next</li>
<li>I&#8217;ve been having luck using SQL Server authentication and not Windows NT authentication (Integrated Security) so I&#8217;m selecting &#8220;With SQL Server authentication&#8230;&#8221; radio button and filling in a SQl Server username and password.</li>
<li>Click Next</li>
<li>Check the &#8220;Change the default database to:&#8221; checkbox and select the database that you want to work with.</li>
<li>Click Next</li>
<li>Click Finish</li>
</ol>
<h3>Create your Rails Application</h3>
<p>From your Command Prompt with Ruby run:  <code>rails sqlservertest</code>.</p>
<h3>Configure the Database Connection</h3>
<p>Edit the database.yml file in the config folder for the rails app.<br />
<code>development:<br />
&nbsp;&nbsp;&nbsp;adapter: sqlserver<br />
&nbsp;&nbsp;&nbsp;mode: odbc<br />
&nbsp;&nbsp;&nbsp;dsn: DSN_NAME<br />
&nbsp;&nbsp;&nbsp;username: USERNAME<br />
&nbsp;&nbsp;&nbsp;password: PASSWORD<br />
&nbsp;&nbsp;&nbsp;host: SERVERNAME</code></p>
<h3>Generate a scaffold to test your database connectivity</h3>
<p>In Rails a scaffold is a powerful technique for doing alot of coding for you by generating controllers, views, models, tests, etc.  Using Rails&#8217; generator create a scaffold for a Customers table with the following command from the Command Prompt with Ruby inside the sqlservertest folder (replace your field names as necessary being careful as Rails is case-sensitive with field names in the database):<br />
<code>ruby script/generate scaffold customer Name:string Address:string City:string State:string Zipcode:string</code><br />
You should now have a customers controller in your app&#8217;s controllers folder, a customers model in your app&#8217;s models folder, a customer&#8217;s folder with edit, index, new, and show views in your app&#8217;s views folder.</p>
<h3>Override Rail&#8217;s default convention for table name and primary key</h3>
<p>If you&#8217;re using SQL Server you probably already have legacy tables that are setup in a manner that Rails&#8217; convention does not work well with.  To fix that we&#8217;re going to tell Rails the table name and primary key for our table.  (Note:  We&#8217;re doing this because Rails expects your primary key to be an identity field named id).  In your customer model place set the table_name and primary_key properties.  The customer.rb file in your models folder should look like the following:<br />
<code>class Customer < ActiveRecord::Base<br />
&nbsp;&nbsp;self.table_name = "Customers"<br />
&nbsp;&nbsp;self.primary_key = "CustomerNum"<br />
end</code></p>
<h3>Run the local development server to verify your configuration</h3>
<p>Inside the sqlservertest folder run the following command in the Command Prompt with Ruby:<br />
<code>ruby script/server</code><br />
Wait a few minutes for the server to start up, then open up a web browser and navigate to http://localhost:3000/customers which will then list all of the customers in your database.  You can click on all of the links available because the scaffolding has generated a working app to create, list, show, edit and delete (aka CRUD) customers for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2010/10/01/getting-rails-to-talk-to-ms-sql-server-from-a-64-bit-windows-7-computer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<series:name><![CDATA[Ruby on Rails on Windows]]></series:name>
	</item>
		<item>
		<title>Developing with Ruby on Rails on Windows 7</title>
		<link>http://www.yanachik.org/2010/09/30/developing-with-ruby-on-rails-on-windows-7/</link>
		<comments>http://www.yanachik.org/2010/09/30/developing-with-ruby-on-rails-on-windows-7/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 18:23:36 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/?p=164</guid>
		<description><![CDATA[My development and production environment is Windows using Microsoft SQL Server, and at this point I have no choice but to continue developing on Windows using Microsoft SQL Server.  My [...]]]></description>
			<content:encoded><![CDATA[<p>My development and production environment is Windows using Microsoft SQL Server, and at this point I have no choice but to continue developing on Windows using Microsoft SQL Server.  My production Rails server can be Linux, but it has to talk to Microsoft SQL Server running on a Windows server.  Here&#8217;s how I setup the development environment on my 64-bit Windows 7 box.</p>
<p>For those not aware, Ruby on Rails is actually a misnomer.  It should be Rails on Ruby, because ruby is a programming language such as C++ and rails is simply a gem (plugin, library, extension) that extends Ruby.  To get started you must install Ruby.</p>
<h1>Ruby</h1>
<p>I installed ruby 1.8.7 locally using <a href="http://rubyinstaller.org">Ruby Installer for Windows</a> using all of the defaults except I checked &#8220;Add Ruby executables to your PATH&#8221;.</p>
<p>A good portion of the remaining installation is done in a command prompt and the best way to make sure Ruby is interpreted correctly is to run a Command Prompt with Ruby.  This is done from the Start Menu &#8211; All Programs &#8211; Ruby 1.8.7 p302 (or whatever version you installed) &#8211; Start Command Prompt with Ruby.</p>
<p>From the command prompt with ruby run the following command to update your system:<br />
<code>gem update --system</code></p>
<h1>Install Rails 2</h1>
<p><strong> </strong>As of this writing Rails 3 has recently been deployed.  Most of the documentation I&#8217;m finding on the web as well as the book I own are all geared towards Rails 2, therefore I want to install Rails 2, not Rails 3.  From the command prompt with ruby rin the following command to install rails:<br />
<code>gem install rails -v=2.3.8</code></p>
<p>After waiting for a while as if nothing was happening a series of successful install messages appeared and a final message of 8 gems installed.  Next the ri and RDoc documentation for the installed gems was installed.</p>
<p>To view the list of installed Gems use the following command:<br />
<code>gem list --local</code></p>
<p>I now have the following gems installed:<br />
actionmailer (2.3.8)<br />
actionpack (2.3.8)<br />
activerecord (2.3.8)<br />
activeresource (2.3.8)<br />
activesupport (2.3.8)<br />
rack (1.1.0)<br />
rails (2.3.8)<br />
rake (0.8.7)</p>
<h1>Non-Microsoft Databases</h1>
<p>You might as well install the gems for Rails to talk with the two default databases MySQL and SQLite.</p>
<h3>MySQL</h3>
<p><code>gem install mysql</code> (I received a series of &#8220;No definition for &#8230;&#8221; errors when the documentation was installed)</p>
<h3>SQLite</h3>
<p><code>gem install sqlite3-ruby</code></p>
<p>This only installs the ruby gem to talk with SQLite, it does not install SQLite on your system.  to install SQLite go to the SQLite download page <a href="http://www.sqlite.org/download.html">http://www.sqlite.org/download.html</a> and download the file sqlitedll-X.X.X.zip under the heading Precompiled Binaries for Windows.  Extract the sqlite3.dll file contained in the downloaded zip to your ruby&#8217;s bin folder.  Mine was located at c:\Ruby187\bin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2010/09/30/developing-with-ruby-on-rails-on-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby on Rails on Windows]]></series:name>
	</item>
		<item>
		<title>A Microsoft Developer migrating to Ruby on Rails</title>
		<link>http://www.yanachik.org/2010/09/30/a-microsoft-developer-migrating-to-ruby-on-rails/</link>
		<comments>http://www.yanachik.org/2010/09/30/a-microsoft-developer-migrating-to-ruby-on-rails/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 17:29:38 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/?p=162</guid>
		<description><![CDATA[I&#8217;ve been a Microsoft developer for my entire career starting with Microsoft Access and Visual Basic through today working on ASP.Net MVC web applications running on .Net 4 using NHibernate [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a Microsoft developer for my entire career starting with Microsoft Access and Visual Basic through today working on ASP.Net MVC web applications running on .Net 4 using NHibernate and Microsoft Test.  The jump from ASP.Net Webforms to ASP.Net MVC was monumental and delayed my leap to Ruby on Rails until now.</p>
<p>Lately it feels as if I&#8217;m fighting with too many configuration, compiler, things I don&#8217;t want to worry about, problems in .Net.  The last few .Net projects that I worked on with a team always seemed to be some odd fight with some piece of code that is not crucial to the success of the project, but is making the entire project fail.  I&#8217;ve been testing out Rails to see if these issues I run into are common across the board, or .Net specific.  They are .Net specific.</p>
<p>All programming systems seem wonderful when looked at from a high-level, it&#8217;s not until you really get into the details when you find out the problems.  And I&#8217;m sure there will be problems.  I just don&#8217;t want to have to deal with repeating problems like I am with .Net.</p>
<p>I like NHibernate and feel as if it&#8217;s the best ORM in the .Net world.  Yet, it&#8217;s lacking features due to design the theoretical decisions (i.e. POCO) that required me to write functionality that I didn&#8217;t want to have to write.  I don&#8217;t want to have to write code to audit/validate my business objects before they go to the database, I want hooks.</p>
<p>Anyways, I will be attempting to migrate my working environment from .Net to Ruby on Rails.  This blog will be my documentation and diary.  Here we go!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2010/09/30/a-microsoft-developer-migrating-to-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby on Rails on Windows]]></series:name>
	</item>
		<item>
		<title>How to return a SQL Report as a PDF/Excel/CSV file from an ASP.Net MVC controller</title>
		<link>http://www.yanachik.org/2010/02/26/how-to-return-a-sql-report-as-a-pdfexcelcsv-file-from-as-asp-net-mvc-controller/</link>
		<comments>http://www.yanachik.org/2010/02/26/how-to-return-a-sql-report-as-a-pdfexcelcsv-file-from-as-asp-net-mvc-controller/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 16:38:24 +0000</pubDate>
		<dc:creator>kyanachik</dc:creator>
				<category><![CDATA[Website Development]]></category>

		<guid isPermaLink="false">http://www.yanachik.org/2010/02/26/how-to-return-a-sql-report-as-a-pdfexcelcsv-file-from-as-asp-net-mvc-controller/</guid>
		<description><![CDATA[SQL Reports is a wonderful tool for creating and publishing enterprise reports, yet it’s Web Forms viewer has it’s drawbacks such as requiring an Active-X control for printing and it’s [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Reports is a wonderful tool for creating and publishing enterprise reports, yet it’s Web Forms viewer has it’s drawbacks such as requiring an Active-X control for printing and it’s not available in ASP.Net MVC.</p>
<p>A good solution to utilizing SQL Reports in an ASP.Net MVC application is to use the SQL Reports Web Services API to render the report as a PDF, Excel, or CSV file and to have your action method return the rendered report as a Filestream to the browser.</p>
<blockquote><p>The source code for this project is available on a Subversion server here:&#160; <a title="http://code.yanachik.org/public/MVCSQLReportDemo/" href="http://code.yanachik.org/public/MVCSQLReportDemo/">http://code.yanachik.org/public/MVCSQLReportDemo/</a></p>
</blockquote>
<h2>The steps involved are:</h2>
<ol>
<li>Create a Web Reference to the SQL Reports Report Execution Web Service. </li>
<li>Create an Action Method that returns a FileStreamResult. </li>
<li>Create a proxy to the Web Service and set the credentials. </li>
<li>Render the report. </li>
<li>Return the report as a file stream. </li>
</ol>
<h3>Create a Web Reference to the SQL Reports Report Execution Web Service</h3>
<p>In your ASP.Net MVC project add a Web-Reference to the Report Execution Web Reference to the following URL:&#160; <a title="http://qasqlserver/ReportServer/ReportExecution2005.asmx" href="http://REPORTSERVER/ReportServer/ReportExecution2005.asmx">http://REPORTSERVER/ReportServer/ReportExecution2005.asmx</a> and name it rsExecService.&#160; Even if you’re using SQL Reports 2008, the Web Reference is still set for 2005.</p>
<p>To do this, right-click on the project in Visual Studio and select Add Web Reference…&#160; The “Add Web Reference” dialog will appear.&#160; Fill in the URL to your SQL Reports Report Execution Web Service and hit enter or click on the Go button.&#160; Once the Web Service is found you fill out the Web Reference Name with rsExecService and click the Add Reference button.</p>
<p><a href="http://www.yanachik.org/wp-content/uploads/2010/02/AddingWebReference.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="AddingWebReference" border="0" alt="AddingWebReference" src="http://www.yanachik.org/wp-content/uploads/2010/02/AddingWebReference_thumb.png" width="244" height="171" /></a> </p>
<h3>Create an Action Method that returns a FileStreamResult</h3>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:17f0787a-1435-47e5-bae2-85484d08b93e" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #000000;">[System.Web.Mvc.OutputCache(NoStore </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">true</span><span style="color: #000000;">, Duration </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">, VaryByParam </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">*</span><span style="color: #800000;">"</span><span style="color: #000000;">)]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> FileStreamResult PrintReport(</span><span style="color: #0000FF;">string</span><span style="color: #000000;"> id)
{

}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>The System.Web.Mvc.OutputCache attribute tells your browser to not cache the report.&#160; If you have static data you can remove this attribute.</p>
<h3>Create a proxy to the Web Service and set the credentials</h3>
<h3>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:1057a4a3-31b2-4a5d-983b-f38a3c12fac9" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #008000;">//</span><span style="color: #008000;"> Create a new proxy to the web service</span><span style="color: #008000;">
</span><span style="color: #000000;">rsExecService.ReportExecutionService rsExec </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> rsExecService.ReportExecutionService();

</span><span style="color: #008000;">//</span><span style="color: #008000;"> Authenticate to the Web service using Windows credentials</span><span style="color: #008000;">
</span><span style="color: #000000;">rsExec.Credentials </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> System.Net.NetworkCredential(</span><span style="color: #800000;">"</span><span style="color: #800000;">USERNAME</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">Password</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">DOMAIN</span><span style="color: #800000;">"</span><span style="color: #000000;">);

</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Render the report</h3>
<p>When loading the report, the file name is the full path for the report.&#160; In this case “Test Report” is at the root of the Report Server.&#160; If it was in a folder then the path would be “/Folder 1/Folder 2/Report Name”.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:b86a741e-8b8b-4ff2-9c1c-59435834126f" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #008000;">//</span><span style="color: #008000;"> Load the selected report.</span><span style="color: #008000;">
</span><span style="color: #000000;">rsExec.LoadReport(</span><span style="color: #800000;">"</span><span style="color: #800000;">/Test Report</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #0000FF;">null</span><span style="color: #000000;">);

</span><span style="color: #008000;">//</span><span style="color: #008000;"> Prepare Render arguments</span><span style="color: #008000;">
</span><span style="color: #0000FF;">string</span><span style="color: #000000;"> encoding </span><span style="color: #000000;">=</span><span style="color: #000000;"> String.Empty;
</span><span style="color: #0000FF;">string</span><span style="color: #000000;"> mimeType </span><span style="color: #000000;">=</span><span style="color: #000000;"> String.Empty;
</span><span style="color: #0000FF;">string</span><span style="color: #000000;"> extension </span><span style="color: #000000;">=</span><span style="color: #000000;"> String.Empty;
rsExecService.Warning[] warnings </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">;
</span><span style="color: #0000FF;">string</span><span style="color: #000000;">[] streamIDs </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">;

</span><span style="color: #008000;">//</span><span style="color: #008000;"> Prepare report parameters.</span><span style="color: #008000;">
</span><span style="color: #000000;">rsExecService.ParameterValue[] parameters </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> rsExecService.ParameterValue[</span><span style="color: #800080;">1</span><span style="color: #000000;">];
parameters[</span><span style="color: #800080;">0</span><span style="color: #000000;">] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> rsExecService.ParameterValue();
parameters[</span><span style="color: #800080;">0</span><span style="color: #000000;">].Value </span><span style="color: #000000;">=</span><span style="color: #000000;"> id;
parameters[</span><span style="color: #800080;">0</span><span style="color: #000000;">].Name </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">id</span><span style="color: #800000;">"</span><span style="color: #000000;">;

</span><span style="color: #008000;">//</span><span style="color: #008000;"> Set the parameters for the report needed.</span><span style="color: #008000;">
</span><span style="color: #000000;">rsExec.SetExecutionParameters(parameters, </span><span style="color: #800000;">"</span><span style="color: #800000;">en-us</span><span style="color: #800000;">"</span><span style="color: #000000;">);

</span><span style="color: #008000;">//</span><span style="color: #008000;">Render the report to a byte[]</span><span style="color: #008000;">
</span><span style="color: #000000;">Byte[] byteInfo </span><span style="color: #000000;">=</span><span style="color: #000000;"> rsExec.Render(</span><span style="color: #800000;">"</span><span style="color: #800000;">PDF</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #0000FF;">null</span><span style="color: #000000;">, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> extension, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> encoding, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> mimeType, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> warnings, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> streamIDs);
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<h3>Return the report as a file stream. </h3>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:a93b91a3-2b77-49a8-bb6c-b0e30344de08" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #000000;">System.IO.MemoryStream ms </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> System.IO.MemoryStream();
ms.Write(byteInfo, </span><span style="color: #800080;">0</span><span style="color: #000000;">, byteInfo.Length);
ms.Position </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">;

HttpContext.Response.AddHeader(</span><span style="color: #800000;">"</span><span style="color: #800000;">content-disposition</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">attachment; filename=FILENAME.pdf</span><span style="color: #800000;">"</span><span style="color: #000000;">);

</span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> FileStreamResult(ms, </span><span style="color: #800000;">"</span><span style="color: #800000;">application/pdf</span><span style="color: #800000;">"</span><span style="color: #000000;">);
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<h3>The final Action Method looks like this:</h3>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:1fc8b796-bbe4-4f15-8679-6836405275cc" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #000000;">[System.Web.Mvc.OutputCache(NoStore </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">true</span><span style="color: #000000;">, Duration </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">, VaryByParam </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">*</span><span style="color: #800000;">"</span><span style="color: #000000;">)]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> FileStreamResult PrintReport(</span><span style="color: #0000FF;">string</span><span style="color: #000000;"> id)
{
    </span><span style="color: #008000;">//</span><span style="color: #008000;"> Create a new proxy to the web service</span><span style="color: #008000;">
</span><span style="color: #000000;">    rsExecService.ReportExecutionService rsExec </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> rsExecService.ReportExecutionService();

    </span><span style="color: #008000;">//</span><span style="color: #008000;"> Authenticate to the Web service using Windows credentials</span><span style="color: #008000;">
</span><span style="color: #000000;">    rsExec.Credentials </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> System.Net.NetworkCredential(</span><span style="color: #800000;">"</span><span style="color: #800000;">USERNAME</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">Password</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">DOMAIN</span><span style="color: #800000;">"</span><span style="color: #000000;">);

    </span><span style="color: #008000;">//</span><span style="color: #008000;"> Load the selected report.</span><span style="color: #008000;">
</span><span style="color: #000000;">    rsExec.LoadReport(</span><span style="color: #800000;">"</span><span style="color: #800000;">/Test Report</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #0000FF;">null</span><span style="color: #000000;">);

    </span><span style="color: #008000;">//</span><span style="color: #008000;"> Prepare Render arguments</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> encoding </span><span style="color: #000000;">=</span><span style="color: #000000;"> String.Empty;
    </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> mimeType </span><span style="color: #000000;">=</span><span style="color: #000000;"> String.Empty;
    </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> extension </span><span style="color: #000000;">=</span><span style="color: #000000;"> String.Empty;
    rsExecService.Warning[] warnings </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">;
    </span><span style="color: #0000FF;">string</span><span style="color: #000000;">[] streamIDs </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">;

    </span><span style="color: #008000;">//</span><span style="color: #008000;"> Prepare report parameters.</span><span style="color: #008000;">
</span><span style="color: #000000;">    rsExecService.ParameterValue[] parameters </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> rsExecService.ParameterValue[</span><span style="color: #800080;">1</span><span style="color: #000000;">];
    parameters[</span><span style="color: #800080;">0</span><span style="color: #000000;">] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> rsExecService.ParameterValue();
    parameters[</span><span style="color: #800080;">0</span><span style="color: #000000;">].Value </span><span style="color: #000000;">=</span><span style="color: #000000;"> id;
    parameters[</span><span style="color: #800080;">0</span><span style="color: #000000;">].Name </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">id</span><span style="color: #800000;">"</span><span style="color: #000000;">;

    </span><span style="color: #008000;">//</span><span style="color: #008000;"> Set the parameters for the report needed.</span><span style="color: #008000;">
</span><span style="color: #000000;">    rsExec.SetExecutionParameters(parameters, </span><span style="color: #800000;">"</span><span style="color: #800000;">en-us</span><span style="color: #800000;">"</span><span style="color: #000000;">);

    </span><span style="color: #008000;">//</span><span style="color: #008000;">Render the report to a byte[]</span><span style="color: #008000;">
</span><span style="color: #000000;">    Byte[] byteInfo </span><span style="color: #000000;">=</span><span style="color: #000000;"> rsExec.Render(</span><span style="color: #800000;">"</span><span style="color: #800000;">PDF</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #0000FF;">null</span><span style="color: #000000;">, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> extension, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> encoding, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> mimeType, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> warnings, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> streamIDs);

    System.IO.MemoryStream ms </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> System.IO.MemoryStream();
    ms.Write(byteInfo, </span><span style="color: #800080;">0</span><span style="color: #000000;">, byteInfo.Length);
    ms.Position </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">;

    HttpContext.Response.AddHeader(</span><span style="color: #800000;">"</span><span style="color: #800000;">content-disposition</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">attachment; filename=FILENAME.pdf</span><span style="color: #800000;">"</span><span style="color: #000000;">);

    </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> FileStreamResult(ms, </span><span style="color: #800000;">"</span><span style="color: #800000;">application/pdf</span><span style="color: #800000;">"</span><span style="color: #000000;">);
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
]]></content:encoded>
			<wfw:commentRss>http://www.yanachik.org/2010/02/26/how-to-return-a-sql-report-as-a-pdfexcelcsv-file-from-as-asp-net-mvc-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

