<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Programmer's Heaven Blogs RSS Feed</title>
    <link>http://www.programmersheaven.com/blog/</link>
    <description>Contains the latest posts from all of the blogs on Programmer's Heaven.</description>
    <lastBuildDate>Fri, 09 May 2008 09:49:23 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <item>
      <title>Me4creative</title>
      <link>http://www.programmersheaven.com/user/rakesh+babu/blog/234-Me4creative/</link>
      <description>hi&lt;br /&gt;
  Think different for new achievements it will give positive results&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/user/rakesh+babu/blog/234-Me4creative/</guid>
      <pubDate>Thu, 08 May 2008 22:21:14 -0700</pubDate>
      <dc:creator>rakesh babu</dc:creator>
    </item>
    <item>
      <title>Tribute to Visual B</title>
      <link>http://www.programmersheaven.com/user/servetus/blog/233-Tribute-to-Visual-B/</link>
      <description>Programming should not just be like cutting codes only, for it essential and adviceable for every good programmer to be knowledgeable in the game of &lt;strong&gt;&lt;span style="font-size: small;"&gt;CHESS&lt;/span&gt;&lt;/strong&gt;. Am say this for reality it is some thing i spot whenever i code with &lt;strong&gt;Visual Basic&lt;/strong&gt;.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/user/servetus/blog/233-Tribute-to-Visual-B/</guid>
      <pubDate>Thu, 08 May 2008 11:50:13 -0700</pubDate>
      <dc:creator>servetus</dc:creator>
    </item>
    <item>
      <title>The start</title>
      <link>http://www.programmersheaven.com/user/himlink/blog/232-The-start/</link>
      <description>Software is like an ocean,big,endless,and full of waves. Reversing is like surfing those waves.  &lt;span style="color: Blue;"&gt;&lt;/span&gt;&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/user/himlink/blog/232-The-start/</guid>
      <pubDate>Thu, 08 May 2008 03:03:04 -0700</pubDate>
      <dc:creator>himlink</dc:creator>
    </item>
    <item>
      <title>Database To Text File</title>
      <link>http://www.programmersheaven.com/user/wiltekg/blog/231-Database-To-Text-File/</link>
      <description>“Database to text file” is a small utility that encourage anyone who need to export the query results into a file. Now, it supports the SQL Server and ODBC connections. Besides export query results into text file, it support to print your query results out with Crystal Report.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;
Features&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
* Export query’s result into text file,&lt;br /&gt;
* Export query’s result into Microsoft Excel, &lt;br /&gt;
* Export or import query setting from developer to end user or vice versa,&lt;br /&gt;
* Easy to maintain the query,&lt;br /&gt;
* Result can be ordered,&lt;br /&gt;
* Flexible filter feature,&lt;br /&gt;
* Support SQL Server and ODBC connection,&lt;br /&gt;
* Preview Query Result,&lt;br /&gt;
* Generating fields definition only (TTX) or XML Schema to support reporting in Crystal Report,&lt;br /&gt;
* Print Query Result using Crystal Report,&lt;br /&gt;
* Shortcuts to access menu,&lt;br /&gt;
* Developed using C# .Net,&lt;br /&gt;
* Long live innovation features in the future,&lt;br /&gt;
* Attached with samples using ODBC for best practice, &lt;br /&gt;
* FREEWARE : Free to use, free to distribute &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How To Use ?&lt;/strong&gt;&lt;br /&gt;
To using this utility, you need to do an installment first. If your computer has not been installed with .Net Framework, you need to installed it first (click here to download).&lt;br /&gt;
This utility can be divided into 2 kind of purpose :&lt;br /&gt;
* Client Using&lt;br /&gt;
* Developer Using &lt;br /&gt;
This utility can be distributed to end user who did not knew about queries. After installation process completed, the utility will perform as “client using” with a query sample displayed. If you need to modify the query, you must switch the utility into the developer state.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How to switch to developer state ?&lt;/strong&gt;&lt;br /&gt;
In order to run at developer state, you need to run from “Run” window, and type this command : dbtottext.exe wiltech-center. Now, you can add your new query, modify the existing query or delete your query.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How to Export the Query’s Setting ?&lt;/strong&gt;&lt;br /&gt;
To export your query setting, you simply click the menu : File &amp;gt; Export Configuration’s Setting With this features, you can get all query setting, including the column setting and connection settings.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How to Import the Query’s Setting ?&lt;/strong&gt;&lt;br /&gt;
To import your query setting, you simply click the menu : File &amp;gt; Import Configuration’s Setting With this features, you can distribute the query to the end user including the columns settings. After imported the setting, you need to close the utility and re-open it again.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How to Print your Query’s Result to Crystal Report?&lt;/strong&gt;&lt;br /&gt;
You must already have a Crystal Report file (*.rpt) that has been design followed the query. If you want to design and need to use field definition from your query, you can generate them by click on File&amp;gt;Generate Field Definition (Ctrl+D), you can chose the file type in order to generate to TTX or XML’s File. After designed your report, from Database To Text Utility, you can print the query result by click on File&amp;gt;Print As Report (Ctrl+P). &lt;br /&gt;
&lt;br /&gt;
See more information and download link at &lt;a href="http://www.wiltech-center.com"&gt;www.wiltech-center.com&lt;/a&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/user/wiltekg/blog/231-Database-To-Text-File/</guid>
      <pubDate>Mon, 05 May 2008 20:05:11 -0700</pubDate>
      <dc:creator>wiltekg</dc:creator>
    </item>
    <item>
      <title>Very Quick Guide To DLinq: Part 3 (LIKE, IN, DATEDIFF)</title>
      <link>http://www.programmersheaven.com/user/pheaven/blog/230-Very-Quick-Guide-To-DLinq-Part-3-LIKE-IN-DATEDIFF/</link>
      <description>Much of the time, it's fairly straightforward to express an SQL query in Linq instead. However, there are some things that aren't quite so clear how to do. In this article, I'll take a look at some of those.&lt;br /&gt;
&lt;br /&gt;
=== LIKE ===&lt;br /&gt;
There are a couple of ways to replace LIKE. If you just want to directly use LIKE, then you can do so using the SqlMethods class. To use this, you must add the following using declaration at the top of the file:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;using System.Data.Linq.SqlClient;&lt;/pre&gt;&lt;br /&gt;
Then we can use it like this:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;var Result = from Book in DB.BookResources
             where &lt;span style="color: Red;"&gt;SqlMethods.Like(Book.Title, "%java%")&lt;/span&gt;
             select Book;&lt;/pre&gt;&lt;br /&gt;
This will create an SQL query that locates all books containing "java" (case-insensitively). Interestingly, you can also do the following:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;var Result = from Book in DB.BookResources
             where &lt;span style="color: Red;"&gt;Book.Title.Contains("java")&lt;/span&gt;
             select Book;&lt;/pre&gt;&lt;br /&gt;
And it is equivalent. This is useful and results in the same SQL, but also a tad confusing: you get the case sensitivity (or default lack thereof) configured in the database, even though normally in C# code outside of a Linq query this method is case sensitive.&lt;br /&gt;
&lt;br /&gt;
You can also use the .StartsWith and .EndsWith methods of a string, which can replace some LIKE queries a little more readably. They have the same case quirks, though (under the hood, they all compile down to a LIKE query).&lt;br /&gt;
&lt;br /&gt;
=== IN ===&lt;br /&gt;
Our example table has a rating field that allows us to store a book's rating out of ten. We want to get those books scoring between 7 and 10 points (or some other arbitrary List of scores). We can use the List's Contains method inside the Linq query, which will cause it to generate an IN query in the SQL.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;var GoodRatings = new List&amp;lt;short&amp;gt;() { 7, 8, 9, 10 };
var Result = from Book in DB.BookResources
             where &lt;span style="color: Red;"&gt;GoodRatings.Contains(Book.Rating)&lt;/span&gt;
             select Book;&lt;/pre&gt;&lt;br /&gt;
Nice and easy.&lt;br /&gt;
&lt;br /&gt;
=== DATEDIFF ===&lt;br /&gt;
The SqlMethods class also contains various methods to allow us to express the SQL DATEDIFF built-in. In the following example, we select all books that were added to the database in the last 30 days.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;var Result = from Book in DB.BookResources
             &lt;span style="color: Red;"&gt;where SqlMethods.DateDiffDay(Book.EntryDate, DateTime.Now) &amp;lt;= 30&lt;/span&gt;
             select Book;&lt;/pre&gt;&lt;br /&gt;
There are a variety of related methods available, including DateDiffYear, DateDiffHour and so forth, depending what unit of time you want to get the result back in. These compile to an SQL DATEDIFF query.&lt;br /&gt;
&lt;br /&gt;
Note that methods on TimeSpan objects are not translated by Linq, therefore you can not write:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;var Result = from Book in DB.BookResources
             where &lt;span style="color: Red;"&gt;DateTime.Now.Subtract(Book.EntryDate.Value).Days &amp;lt; 30&lt;/span&gt;
             select Book;&lt;/pre&gt;&lt;br /&gt;
Trying to do so will give you a NotSupportedException at runtime (unfortunately meaning that you won't find out that this won't work at compile time).&lt;br /&gt;
&lt;br /&gt;
=== If All Else Fails ===&lt;br /&gt;
If you are really stuck trying to express a tricky SQL query in Linq, but using Linq generally, then you can still use the DataContext's ExecuteQuery method to send a query directly to the database in SQL.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;var Result = DB.ExecuteQuery&amp;lt;BookResource&amp;gt;(
    "SELECT * FROM [BookResources] WHERE Title LIKE '%java%'");&lt;/pre&gt;&lt;br /&gt;
We use a type parameter to specify the type of object that will contain the result of our query, then just specify the query to execute as a string. Note that we could have expressed this one in Linq, it's just an example.&lt;br /&gt;
&lt;br /&gt;
If you want to just get one field, write the type of that field.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;var Result = DB.ExecuteQuery&amp;lt;string&amp;gt;(
    "SELECT [Title] FROM [BookResources] WHERE Title LIKE '%java%'");&lt;/pre&gt;&lt;br /&gt;
If you're getting a few fields back, then you will probably need to create a class with properties that have names matching those of the fields that you use in the query. However, there is another variant of ExecuteQuery that takes a Type object as a first parameter, so you can most probably instantiate an anonymous type using new() { ... } with some dummy values to get the member types correct, then call GetType and pass that as the parameter. I'll leave testing this beautiful bit of evil as an exercise for the reader. &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
=== Final Thoughts ===&lt;br /&gt;
Linq works to make working with databases feel close to working with other objects in your program. Thus IN feels very natural and, while they provide a direct way to use LIKE, some methods of the String class are usable too. However, in some cases you have to fall back to using some of the methods in the SqlMethods class, and in an extreme few further cases you might need to drop all the way back to using SQL.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/user/pheaven/blog/230-Very-Quick-Guide-To-DLinq-Part-3-LIKE-IN-DATEDIFF/</guid>
      <pubDate>Wed, 30 Apr 2008 06:50:28 -0700</pubDate>
      <dc:creator>pheaven</dc:creator>
    </item>
  </channel>
</rss>