<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Nishanth Nair's .Net Weblog</title>
	<atom:link href="http://dotnetrocks.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotnetrocks.wordpress.com</link>
	<description>This blog contains intersting facts about C#, .NET, ASP.NET, Ajax and latest happenings in Microsoft Technologies</description>
	<lastBuildDate>Wed, 21 May 2008 07:12:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='dotnetrocks.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Nishanth Nair's .Net Weblog</title>
		<link>http://dotnetrocks.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://dotnetrocks.wordpress.com/osd.xml" title="Nishanth Nair&#039;s .Net Weblog" />
	<atom:link rel='hub' href='http://dotnetrocks.wordpress.com/?pushpress=hub'/>
		<item>
		<title>My cousin&#8217;s son Saurav in action[Malayalam converstaion]</title>
		<link>http://dotnetrocks.wordpress.com/2008/05/21/my-cousins-son-saurav-in-actionmalayalam-converstaion/</link>
		<comments>http://dotnetrocks.wordpress.com/2008/05/21/my-cousins-son-saurav-in-actionmalayalam-converstaion/#comments</comments>
		<pubDate>Wed, 21 May 2008 07:01:47 +0000</pubDate>
		<dc:creator>Nishanth Nair</dc:creator>
				<category><![CDATA[Family]]></category>
		<category><![CDATA[funny]]></category>
		<category><![CDATA[jokes]]></category>
		<category><![CDATA[kid]]></category>
		<category><![CDATA[saurav]]></category>

		<guid isPermaLink="false">http://dotnetrocks.wordpress.com/?p=9</guid>
		<description><![CDATA[<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=9&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<span style="text-align:center; display: block;"><a href="http://dotnetrocks.wordpress.com/2008/05/21/my-cousins-son-saurav-in-actionmalayalam-converstaion/"><img src="http://img.youtube.com/vi/LgvntNAOA98/2.jpg" alt="" /></a></span>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotnetrocks.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotnetrocks.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetrocks.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetrocks.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetrocks.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetrocks.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotnetrocks.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotnetrocks.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotnetrocks.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotnetrocks.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetrocks.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetrocks.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetrocks.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetrocks.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetrocks.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetrocks.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=9&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotnetrocks.wordpress.com/2008/05/21/my-cousins-son-saurav-in-actionmalayalam-converstaion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6fd6deb1715f586bb0604a54c4afa10b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Nishanth</media:title>
		</media:content>
	</item>
		<item>
		<title>Article on why not to use * in SQL Queries</title>
		<link>http://dotnetrocks.wordpress.com/2008/05/02/article-on-why-not-to-use-in-sql-queries/</link>
		<comments>http://dotnetrocks.wordpress.com/2008/05/02/article-on-why-not-to-use-in-sql-queries/#comments</comments>
		<pubDate>Fri, 02 May 2008 05:14:19 +0000</pubDate>
		<dc:creator>Nishanth Nair</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[asterik in sql queries]]></category>
		<category><![CDATA[not to use asterik in sql queries]]></category>
		<category><![CDATA[SQL Central]]></category>
		<category><![CDATA[SQL QUeries]]></category>

		<guid isPermaLink="false">http://dotnetrocks.wordpress.com/?p=8</guid>
		<description><![CDATA[Today I got to read a very good article on SqlCentral.com. This about a simple example(one of many scenarios ) why developers should not use ‘*’ when writing SQL queries. I felt all developers should read this article as the issue addressed is something that may occur frequently in daily development. Interesting things that you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=8&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span style="color:black;">Today I got to read a very good article on SqlCentral.com. This about a simple example(one of many scenarios ) why developers should not use ‘*’ when writing SQL queries. <span> </span>I felt all developers should read this article as the issue addressed is something that may occur frequently in daily development.</span></p>
<p class="MsoNormal"><span style="color:black;">Interesting things that you will learn <span> </span>about this article are:</span></p>
<p class="MsoListParagraphCxSpFirst" style="text-indent:-0.25in;"><span style="color:#140377;"><span>1.<span> </span></span></span><span style="color:black;">One main difference between User defined functions and SPs(how table structure is stored in system tables in case of UDF and this is updated only when Create function is called which is not the case in Stored procedures)</span></p>
<p class="MsoListParagraphCxSpLast" style="text-indent:-0.25in;"><span style="color:#140377;"><span>2.<span> </span></span></span><span style="color:black;">How to easily get a list of columns in a table as comma separated values which will be helpful while writing column names of tables having lots of columns(Especially for people like me who are Excel illiterates </span><span style="font-family:Wingdings;color:black;"><span>J</span></span><span style="color:black;"> )</span></p>
<p class="MsoNormal">Link to <span> </span>the article: <a href="http://www.sqlservercentral.com/articles/UDF/62730/">http://www.sqlservercentral.com/articles/UDF/62730/</a></p>
<p class="MsoNormal"><strong><em>Note: To read the article you will have to resgister with SQLCentral.com which is worth it!</em></strong></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotnetrocks.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotnetrocks.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetrocks.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetrocks.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetrocks.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetrocks.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotnetrocks.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotnetrocks.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotnetrocks.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotnetrocks.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetrocks.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetrocks.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetrocks.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetrocks.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetrocks.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetrocks.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=8&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotnetrocks.wordpress.com/2008/05/02/article-on-why-not-to-use-in-sql-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6fd6deb1715f586bb0604a54c4afa10b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Nishanth</media:title>
		</media:content>
	</item>
		<item>
		<title>Validating an XML File using XSD in .NET .20</title>
		<link>http://dotnetrocks.wordpress.com/2008/05/02/validating-an-xml-file-using-xsd-in-net-20/</link>
		<comments>http://dotnetrocks.wordpress.com/2008/05/02/validating-an-xml-file-using-xsd-in-net-20/#comments</comments>
		<pubDate>Fri, 02 May 2008 04:49:26 +0000</pubDate>
		<dc:creator>Nishanth Nair</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://dotnetrocks.wordpress.com/?p=7</guid>
		<description><![CDATA[Below given is the.NET 1.1 code for validating an XML File using an XSD File. .NET 1.1 Code //.NET1.1 code /// /// Methode to validate XML File /// /// This method expects input XML as string /// Path to schema file /// true if xml is validated else false private bool ValidateXmlUsingXsd(string XmlData,String SchemaPath) { [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=7&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#009900;">Below given is the.NET 1.1 code for validating  an XML File using an XSD File.</span></p>
<p>.NET 1.1 Code</p>
<p>//.NET1.1  code<br />
///<br />
/// Methode to validate XML File<br />
///<br />
///</p>
<div class="post-body entry-content">
This method expects input XML as  string<br />
///<br />
Path to schema  file<br />
/// true if xml is validated else  false<br />
<span style="color:#339999;">private bool  ValidateXmlUsingXsd(string XmlData,String  SchemaPath)<br />
{<br />
XmlValidatingReader v = new XmlValidatingReader(XmlData,  XmlNodeType.Document, null);<br />
v.ValidationType = ValidationType.Schema;<br />
v.ValidationEventHandler +=<br />
new  ValidationEventHandler(MyValidationEventHandler);</p>
<p>while  (v.Read())<br />
{<br />
// Can add code here to process the  content.<br />
}<br />
v.Close();</p>
<p>return isValid;</p>
<p>}<br />
</span>///<br />
/// This event handler is called only when a validation error  occurs<br />
///<br />
///</p>
<p>///</p>
<p><span style="color:#339999;">public static void  MyValidationEventHandler(object sender,<br />
ValidationEventArgs  args)<br />
{<br />
//these two variables should be initialized as class level  variables<br />
isValid = false;<br />
errorMessage = &#8220;Validation event\n&#8221; +  args.Message;</p>
<p>}<br />
</span>///<br />
/// Method to get XML in a  string from an XML file<br />
///<br />
///</p>
<p>///<br />
<span style="color:#339999;">private string GetStringFromXML(string  fileName)<br />
{<br />
StreamReader rd = new StreamReader(fileName);<br />
string str =  rd.ReadToEnd();<br />
rd.Close();<br />
return  str;<br />
}<br />
</span></p>
<p>Calling the method :<br />
<span style="color:#339999;">bool valid = ValidateXmlUsingXsd(str,  txtXSD.Text);<br />
</span></p>
<p>There are some changes in the .NET 2.0 code for  XML Validation .<br />
<span style="color:#33cc00;">XmlValidatingReader</span> is  marked as obsolete. Need to use <span style="color:#33cc00;">XMLReader.Create()</span> using <span style="color:#33cc00;">XmlReaderSettngs</span> instead</p>
<p>There are some  behavioral changes between validation using the XmlReaderSettings and  XmlSchemaSet classes and validation using the XmlValidatingReader  class.</p>
<p>The XmlReaderSettings and XmlSchemaSet classes do not support  XML-Data Reduced (XDR) schema validation.</p>
<p>The most important difference I  found out is that to do XML data validation using a schema, <span style="color:#ff0000;"><strong>settings.ValidationFlags =  XmlSchemaValidationFlags.ReportValidationWarnings;</strong></span><br />
Flag must  be enabled. <span style="color:#cc0000;">Otherwise the Schema check error will  not be displayed</span>.</p>
<p>//.NET2.0 code<br />
<span style="color:#339999;">private bool ValidateXmlUsingXsd2(string XmlData,String  SchemaPath)<br />
{<br />
XmlReaderSettings settings = new  XmlReaderSettings();<br />
settings.ValidationType =  ValidationType.Schema;<br />
settings.Schemas.Add(null, SchemaPath);<br />
settings.ValidationFlags =  XmlSchemaValidationFlags.ReportValidationWarnings;<br />
settings.ValidationEventHandler += new  ValidationEventHandler(ValidationCallBack);</p>
<p>StringReader xmlStream = new  StringReader(XmlData);<br />
XmlReader reader = XmlReader.Create(xmlStream,  settings);<br />
while (reader.Read()) ;</p>
<p>return isValid;<br />
}</p>
<p>private static void ValidationCallBack(object sender,  ValidationEventArgs e)<br />
{<br />
isValid = false;<br />
errorMessage = &#8220;Validation  Error: &#8221; + e.Message;<br />
}</p>
<p></span><br />
More about XmlSchemaValidationFlags  Enumeration</p>
<p><a name="membersToggle"></a><br />
Member  name<br />
Description<br />
<strong><span style="color:#006600;"><span style="color:#000099;">AllowXmlAttributes</span><br />
</span></strong>Allow xml:*  attributes even if they are not defined in the schema. The attributes will be  validated based on their data type.<br />
<span style="color:#000099;"><strong>None</strong></span><br />
Do not process identity  constraints, inline schemas, schema location hints, or report schema validation  warnings.<br />
<span style="color:#000099;"><strong>ProcessIdentityConstraints<br />
</strong></span>Process  identity constraints (xs:ID, xs:IDREF, xs:key, xs:keyref, xs:unique) encountered  during validation.<br />
<span style="color:#000099;"><strong>ProcessInlineSchema</strong></span><br />
Process  inline schemas encountered during validation.<br />
<strong><span style="color:#000099;">ProcessSchemaLocation</span></strong><br />
Process schema  location hints (xsi:schemaLocation, xsi:noNamespaceSchemaLocation) encountered  during validation.<br />
<span style="color:#ff0000;"><strong>ReportValidationWarnings</strong></span><br />
Report  schema validation warnings encountered during validation.</p>
<p><span style="color:#cc0000;"><strong>In a nutshell, Always set  settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings;  when a schema validation is required for the XML in .NET 2.0</strong></span><br />Nishanth<br />
www.necab.org</p>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotnetrocks.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotnetrocks.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetrocks.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetrocks.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetrocks.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetrocks.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotnetrocks.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotnetrocks.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotnetrocks.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotnetrocks.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetrocks.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetrocks.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetrocks.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetrocks.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetrocks.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetrocks.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=7&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotnetrocks.wordpress.com/2008/05/02/validating-an-xml-file-using-xsd-in-net-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6fd6deb1715f586bb0604a54c4afa10b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Nishanth</media:title>
		</media:content>
	</item>
		<item>
		<title>Truncation of fields when CSV file is read using ADO.NET</title>
		<link>http://dotnetrocks.wordpress.com/2008/05/02/truncation-of-fields-when-csv-file-is-read-using-adonet/</link>
		<comments>http://dotnetrocks.wordpress.com/2008/05/02/truncation-of-fields-when-csv-file-is-read-using-adonet/#comments</comments>
		<pubDate>Fri, 02 May 2008 04:47:31 +0000</pubDate>
		<dc:creator>Nishanth Nair</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ADO.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ado.net issues]]></category>
		<category><![CDATA[csv file]]></category>
		<category><![CDATA[csv file reader issues]]></category>

		<guid isPermaLink="false">http://dotnetrocks.wordpress.com/?p=6</guid>
		<description><![CDATA[I encountered a major problem with ADO.NET CSV reader in one of the projects where CSV File Import played a major role. When a field in the CSV file with a “–“(hyphen) is read, the characters before the “–“are discarded. For example the model F-150 is read as –150 and T-Bird in the model field [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=6&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#000066;">I encountered a major problem with ADO.NET CSV  reader in one of the projects where CSV File Import played a major role.<br />
When  a field in the CSV file with a “–“(hyphen) is read, the characters before the  “–“are discarded. For example the model F-150 is read as –150 and T-Bird in the  model field is not being read. And some of the values were missing in some of  the fields.<br />
Given below is the code I used :</p>
<p><span style="color:#339999;">string strConnString =  &#8220;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&#8221; + folderName + &#8220;;Extended  Properties=\&#8221;text;HDR=Yes; FMT=Delimited\&#8221;";<br />
string sqlSelect = &#8220;select *  from [" + fileName + "]&#8220;;<br />
System.Data.OleDb.OleDbConnection conn = new  System.Data.OleDb.OleDbConnection(<br />
strConnString.Trim());<br />
conn.Open();<br />
System.Data.OleDb.OleDbDataAdapter  adapter = new System.Data.OleDb.OleDbDataAdapter(sqlSelect, conn);<br />
DataSet ds  = new DataSet();<br />
adapter.Fill(ds, &#8220;Inventory&#8221;);<br />
return ds.Tables[0]; </span></p>
<p>Samir found a solution, to add a schema file which identifies all  fields in the csv file as string values.<br />
And call DataSet.ReadXMLSchema()  method to attach the schema to the DataSet. Also the schema constraints are not  enforced .</p>
<p>modified code looks like this..</p>
<p></span><span style="color:#339999;">string strConnString =  &#8220;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&#8221; + folderName + &#8220;;Extended  Properties=\&#8221;text;HDR=Yes; FMT=Delimited; IMEX=1\&#8221;";<br />
string sqlSelect =  &#8220;select * from [" + fileName + "]&#8220;;<br />
System.Data.OleDb.OleDbConnection conn =  new  System.Data.OleDb.OleDbConnection(strConnString.Trim());<br />
conn.Open();<br />
System.Data.OleDb.OleDbDataAdapter  adapter = new System.Data.OleDb.OleDbDataAdapter(sqlSelect, conn);<br />
DataSet ds  = new DataSet();</p>
<p></span><span style="color:#339999;"><span style="color:#ff0000;"><strong>ds.ReadXmlSchema(Server.MapPath(&#8220;xmlschema.xsd&#8221;));<br />
ds.EnforceConstraints  = false;</strong> </span></p>
<p>adapter.Fill(ds, &#8220;Inventory&#8221;);<br />
return  ds.Tables[0]; </span><span style="color:#000066;"></p>
<p>Even after using this  code values like &#8220;F-150&#8243; was read as -150 if there is only one row in the csv  file. </span><br />
<span style="color:#ff0000;">F-100 reads as -100<br />
K-100 reads  as -100<br />
S-100 reads as -100</span><br />
<span style="color:#ff0000;">100-F  reads as -100<br />
100-K reads as -100<br />
100-S reads as -100<br />
100$F reads as  100<br />
100$K reads as 100<br />
100$S reads as 100<br />
F100 reads as 100<br />
K100  reads as 100<br />
S100 reads as 100<br />
F\100 reads as 100<br />
K\100 reads as  100<br />
S\100 reads as 100<br />
F.100 reads as .1<br />
K.100 reads as .1<br />
S.100  reads as .1<br />
K-.\\$$$.\\1 reads as -0.1<br />
K\\-22..$$\\21 reads as  -22.221<br />
-$\.FSK1 reads as -0.1</span><br />
<span style="color:#333399;">This  happens only wen there is only one row in the csv file or more than half the  values in a column is having the avove specified values</span></p>
<p><span style="color:#000066;">May be because  ADO.NET does some internal calculation to treat F as floating point or  something.. The fun part is that f-150 is read correctly.. problem is with  capital letters <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . </span><br />
<span style="color:#000066;">So we ended up  using a custom third party csv reader . </span><br />
<span style="color:#000066;">Moral of the story&#8230; never use ADO.NET csv reader&#8230;  Always go for a custom CSV parser or a third party library. </span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotnetrocks.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotnetrocks.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetrocks.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetrocks.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetrocks.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetrocks.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotnetrocks.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotnetrocks.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotnetrocks.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotnetrocks.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetrocks.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetrocks.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetrocks.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetrocks.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetrocks.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetrocks.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=6&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotnetrocks.wordpress.com/2008/05/02/truncation-of-fields-when-csv-file-is-read-using-adonet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6fd6deb1715f586bb0604a54c4afa10b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Nishanth</media:title>
		</media:content>
	</item>
		<item>
		<title>Method to sort an array of strings in descending order of number of words in each array element</title>
		<link>http://dotnetrocks.wordpress.com/2008/05/02/method-to-sort-an-array-of-strings-in-descending-order-of-number-of-words-in-each-array-element/</link>
		<comments>http://dotnetrocks.wordpress.com/2008/05/02/method-to-sort-an-array-of-strings-in-descending-order-of-number-of-words-in-each-array-element/#comments</comments>
		<pubDate>Fri, 02 May 2008 04:44:32 +0000</pubDate>
		<dc:creator>Nishanth Nair</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[in descending order]]></category>
		<category><![CDATA[sort an array of strings]]></category>
		<category><![CDATA[sort array of strings]]></category>
		<category><![CDATA[sort strings]]></category>

		<guid isPermaLink="false">http://dotnetrocks.wordpress.com/?p=5</guid>
		<description><![CDATA[Just adding a method which i wrote for an application for which the requirement was scrapped. Hope someone can refer to this silly method. /// /// Method to sort an array of strings in descending order of number of words in each array element /// /// Array to be sorted /// Array sorted in descending [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=5&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just adding a method which i wrote for an application for which the  requirement was scrapped.<br />
Hope someone can refer to this silly method.  <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span style="color:#339999;">///<br />
/// Method to sort an  array of strings in descending order of number of words in each array  element<br />
///<br />
/// </span></p>
<div class="post-body entry-content">
Array to be  sorted<br />
/// Array sorted in descending order of number of  words in each array element</p>
<p><span style="color:#990000;">private static string[]  SortArrayWithDescendingWordCount(string[] strArray)<br />
{<br />
<span style="color:#339999;">//Array to store the number of words in each string of  the array to be sorted<br />
</span>int[] wordLengths = new  int[strArray.Length];<br />
<span style="color:#339999;">//variable to keep track  of array index of wordLengths array.<br />
</span>int arrayIndex = 0;<br />
foreach  (string str in strArray)<br />
{<br />
<span style="color:#339999;">//split the string  in to an array of words and store the word count in wordLengths  array.<br />
</span>wordLengths[arrayIndex] = str.Split(&#8216; &#8216;).Length;  ;<br />
arrayIndex++;<br />
}<br />
<span style="color:#339999;">//Sort arrays(ascending  order) by taking wordLenths array as key and strArray as  value</span><br />
Array.Sort(wordLengths, strArray);<br />
<span style="color:#339999;">//now reverse strArray array to sort the array in  descending order of number of words in each array  element<br />
</span>Array.Reverse(strArray);<br />
return strArray;<br />
} </span></p>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotnetrocks.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotnetrocks.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetrocks.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetrocks.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetrocks.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetrocks.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotnetrocks.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotnetrocks.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotnetrocks.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotnetrocks.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetrocks.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetrocks.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetrocks.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetrocks.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetrocks.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetrocks.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=5&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotnetrocks.wordpress.com/2008/05/02/method-to-sort-an-array-of-strings-in-descending-order-of-number-of-words-in-each-array-element/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6fd6deb1715f586bb0604a54c4afa10b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Nishanth</media:title>
		</media:content>
	</item>
		<item>
		<title>A common SQL Query</title>
		<link>http://dotnetrocks.wordpress.com/2008/04/11/a-common-sql-query/</link>
		<comments>http://dotnetrocks.wordpress.com/2008/04/11/a-common-sql-query/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 17:36:36 +0000</pubDate>
		<dc:creator>Nishanth Nair</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[SQL query for finding the 2nd highest marks]]></category>
		<category><![CDATA[SQL query for finding the 2nd highest salary]]></category>
		<category><![CDATA[SQL query for finding the 2nd highest scores]]></category>

		<guid isPermaLink="false">http://dotnetrocks.wordpress.com/?p=3</guid>
		<description><![CDATA[This is a very simple SQL query for finding the 2nd highest salary from an employee table. A very common question in .NET interviews. The query is pretty self explanatory. select  top(1)[Name],Salary from Employee where  salary  not in (select top (1) salary from employee order by salary desc) – Change the top parameter to (nth highest salary [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=3&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="line-height:normal;"><strong><span style="font-size:10pt;font-family:&quot;">This is a very simple SQL query for finding the 2nd highest salary from an employee table.</span></strong></p>
<p class="MsoNormal" style="line-height:normal;"><strong><span style="font-size:10pt;font-family:&quot;">A very common question in .NET interviews. The query is pretty self explanatory.</span></strong><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:15.9pt;"><strong><span style="font-size:10pt;font-family:&quot;color:#0070c0;">select  top(1)[Name],Salary from Employee</span></strong></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:15.9pt;"><strong><span style="font-size:10pt;font-family:&quot;color:#0070c0;"> where  salary  not in (select top (1) salary from employee order by salary desc) </span></strong></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:15.9pt;"><strong><span style="font-size:10pt;font-family:&quot;color:#0070c0;">– Change the top parameter to (nth highest salary &#8211; 1) </span></strong></p>
<p class="MsoNormal"><strong><em> </em></strong></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dotnetrocks.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dotnetrocks.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetrocks.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetrocks.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetrocks.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetrocks.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dotnetrocks.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dotnetrocks.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dotnetrocks.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dotnetrocks.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetrocks.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetrocks.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetrocks.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetrocks.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetrocks.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetrocks.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetrocks.wordpress.com&amp;blog=3451931&amp;post=3&amp;subd=dotnetrocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dotnetrocks.wordpress.com/2008/04/11/a-common-sql-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6fd6deb1715f586bb0604a54c4afa10b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Nishanth</media:title>
		</media:content>
	</item>
	</channel>
</rss>
