<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TechiesWeb &#187; C#</title>
	<atom:link href="http://www.techiesweb.net/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techiesweb.net</link>
	<description>Programming tips &#38; tricks,What went wrong while coding,Code snippets,ASP,ASP.NET,PHP,MySQL,SQL Server,jQuery,AJAX</description>
	<lastBuildDate>Tue, 22 Dec 2009 10:21:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Reading records from an Excel file and Insert to Database in ASP.NET C#</title>
		<link>http://www.techiesweb.net/2009/12/reading-records-excel-file-insert-database-aspnet/</link>
		<comments>http://www.techiesweb.net/2009/12/reading-records-excel-file-insert-database-aspnet/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 10:17:37 +0000</pubDate>
		<dc:creator>Shyju</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.techiesweb.net/?p=60</guid>
		<description><![CDATA[Most of the application which handles with bulk amount of data needs an import facility.Recently i also came across the same situation where i had to read data from an excel file and insert ito to the backend &#8211; Database table.
It s quite simple.Lets look at the solution.
Lets start.. Initially I am uploading the excel [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the application which handles with bulk amount of data needs an import facility.Recently i also came across the same situation where i had to read data from an excel file and insert ito to the backend &#8211; Database table.<br />
It s quite simple.Lets look at the solution.<br />
Lets start.. Initially I am uploading the excel file which user submitted to somewhere in the server</p>
<p><span style="color: #0000ff;">string tempExcelFileUploadPath=&#8221;";<br />
try {<br />
tempExcelFileUploadPath = &#8220;Excelstore/TempFiles/&#8221;;<br />
tempExcelFileUploadPath = Server.MapPath(tempExcelFileUploadPath);<br />
if (!Directory.Exists(tempExcelFileUploadPath))� // If directory not exist, create a new one<br />
{<br />
Directory.CreateDirectory(tempExcelFileUploadPath);<br />
}<br />
tempFilePath = tempExcelFileUploadPath + &#8220;\\tempExcelFile.xls&#8221;;<br />
excelUploader.PostedFile.SaveAs(tempFilePath);<br />
Response.Write(&#8220;&lt;br&gt;&lt;font face=&#8217;Verdana&#8217; &gt; Excel file Uploaded &#8230;&lt;/font&gt;&#8221;);<br />
}<br />
catch (Exception er)<br />
{</span></p>
<p><span style="color: #0000ff;"> Response.Write(&#8220;&lt;br&gt;&lt;font face=&#8217;Verdana&#8217; &gt; Error in excel file upload ! &lt;/font&gt;&#8221;); Response.Write(&#8220;&lt;br&gt;&#8221; + er.ToString());<br />
}</span></p>
<p>Now we have uploaded the excel file to server.The file is located in the folder Excelstore/TempFiles with the name as tempExcelFile.xls. Now we wanto read the data from this file .for this we are using an Oledb connection (Import the</p>
<p>System.Data.OleDb to our program)</p>
<p>Ex : <span style="color: #0000ff;">using System.Data.OleDb; OleDbConnection con = new </span><span style="color: #0000ff;">OleDbConnection(&#8220;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&#8221; + tempFilePath + &#8220;;Extended Properties=Excel 8.0&#8243;);</span><br />
// Create an object of OleDBConnection class<br />
<span style="color: #0000ff;">con.Open();</span>// Open the connection<br />
<span style="color: #0000ff;">try {</span> //Create Dataset and fill with information from the Excel Spreadsheet for easier reference<br />
<span style="color: #0000ff;">DataSet myDataSet = new DataSet();<br />
SqlCommand objCmd = new SqlCommand();<br />
OleDbDataAdapter myCommand = new OleDbDataAdapter(&#8220;SELECT * from [Sheet1$]&#8220;, con);</span></p>
<p><span style="color: #0000ff;">myCommand.Fill(myDataSet);<br />
con.Close();</span><br />
<span style="color: #0000ff;">DataTable dTblManu;<br />
dTblManu = new DataTable();<br />
DataTable dt = myDataSet.Tables[0];<br />
Response.Write(&#8221; Reading data from Excel file :&#8230;&#8230;&#8230;.&#8221;);</span><br />
<span style="color: #0000ff;">foreach (DataRow dr in dt.Rows)<br />
{<br />
if (dr[0].ToString() != &#8220;&#8221;)<br />
{<br />
name=d r[0].ToString();<br />
age=d r[1].ToString(); // Now the variable &#8216; name&#8217; is holding the value of the first record&#8217;s name column </span></p>
<p><span style="color: #0000ff;">// Code to insert this data to DB (Build an inser query here)<br />
<span style="color: #0000ff;">/<span style="color: #0000ff;">/ Ex : string sqlInsert=&#8221;insert into students (name,age) values</span></span></span></p>
<p><span style="color: #0000ff;">(&#8216;&#8221;+name+&#8221;&#8216;,&#8221;+age+&#8221;)&#8221;; //execute the query<br />
}</span></p>
<p><span style="color: #0000ff;"><span style="color: #0000ff;"> </span>} </span></p>
<p><span style="color: #0000ff;">catch (Exception ex1) </span></p>
<p><span style="color: #0000ff;">{ </span></p>
<p><span style="color: #0000ff;"> //Write excpetion handling code heree</span></p>
<p><span style="color: #0000ff;"> }</span></p>
<p>Thats all you need. Try this. If you  face any difficulty in following this,<br />
Please let me know it. Hapy yo HELP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techiesweb.net/2009/12/reading-records-excel-file-insert-database-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS missing while using Response.Write in ASP.NET page</title>
		<link>http://www.techiesweb.net/2009/12/css-missing-while-using-response-write-in-asp-net-page/</link>
		<comments>http://www.techiesweb.net/2009/12/css-missing-while-using-response-write-in-asp-net-page/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 10:43:44 +0000</pubDate>
		<dc:creator>Shyju</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Codebehind]]></category>
		<category><![CDATA[CSS.RegisterStartupScript]]></category>
		<category><![CDATA[Response.Write]]></category>

		<guid isPermaLink="false">http://www.techiesweb.net/?p=25</guid>
		<description><![CDATA[When you are using response.write in your server side code behind page (C# or vb) for an ASP.NET page,The styles of page /CSS seems to be disappeared.Have you ever come across this problem ? Here is the solution to get rid of the probelm .
Instead of simply writing Response.Write, Use &#8221; Page.ClientScript.RegisterStartupScript&#8221;
Ex : string strRenderImg=@&#8221;&#60;img [...]]]></description>
			<content:encoded><![CDATA[<p>When you are using response.write in your server side code behind page (C# or vb) for an ASP.NET page,The styles of page /CSS seems to be disappeared.Have you ever come across this problem ? Here is the solution to get rid of the probelm .</p>
<p>Instead of simply writing Response.Write, Use &#8221; Page.ClientScript.RegisterStartupScript&#8221;</p>
<p><span style="color: #0000ff;">Ex : string strRenderImg=@&#8221;&lt;img src=&#8217;company_logo1.gif&#8217; align=&#8217;center&#8217; /&gt;&#8221;;</span></p>
<p><span style="color: #0000ff;">Page.ClientScript.RegisterStartupScript(this.GetType(), &#8220;strRenderImg&#8221;, strRenderImg);</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techiesweb.net/2009/12/css-missing-while-using-response-write-in-asp-net-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# : How to Create a DateTime object from a string date</title>
		<link>http://www.techiesweb.net/2009/12/c-how-to-create-a-datetime-object-from-a-string-date/</link>
		<comments>http://www.techiesweb.net/2009/12/c-how-to-create-a-datetime-object-from-a-string-date/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 13:36:28 +0000</pubDate>
		<dc:creator>Shyju</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[DateTime]]></category>
		<category><![CDATA[DateTime.Parse]]></category>
		<category><![CDATA[Parse]]></category>

		<guid isPermaLink="false">http://www.techiesweb.net/?p=20</guid>
		<description><![CDATA[In C#, Creating a DateTime object from a Date String is as follows.
 string strStartDate=&#8221;11/11/2009&#8243;;
DateTime objStartDate = DateTime.Parse(strStartDate);
The objStartDate object,which is an object of DateTime class,  is now holding the date and u can use this object for all date manipulation functions
Always use DateTime wherever handling the dates instead of using String.DateTime gives u flexibility [...]]]></description>
			<content:encoded><![CDATA[<p>In C#, Creating a DateTime object from a Date String is as follows.</p>
<p><span style="color: #0000ff;"> string strStartDate=&#8221;11/11/2009&#8243;;</span></p>
<p><span style="color: #0000ff;">DateTime objStartDate = DateTime.Parse(strStartDate);</span></p>
<p>The objStartDate object,which is an object of DateTime class,  is now holding the date and u can use this object for all date manipulation functions</p>
<p>Always use DateTime wherever handling the dates instead of using String.DateTime gives u flexibility to work more on that like performing date manipulation</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techiesweb.net/2009/12/c-how-to-create-a-datetime-object-from-a-string-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get User desktop folder path in C#</title>
		<link>http://www.techiesweb.net/2008/07/get-user-desktop-folder-path-in-c/</link>
		<comments>http://www.techiesweb.net/2008/07/get-user-desktop-folder-path-in-c/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 05:03:53 +0000</pubDate>
		<dc:creator>Shyju</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MicroSoft]]></category>
		<category><![CDATA[Getting User Desktop folder location]]></category>
		<category><![CDATA[System.Environment]]></category>
		<category><![CDATA[User desktop folder path]]></category>

		<guid isPermaLink="false">http://techiesweb.wordpress.com/?p=22</guid>
		<description><![CDATA[How to Get the Path to the User desktop in C#.NET ? Here is the single line  Code
string strPath=Environment.GetFolderPath(System.Environ
ment.SpecialFolder.DesktopDirectory).ToString();
OUTPUT looks like this..
F:\Documents and Settings\Shyju\Desktop
]]></description>
			<content:encoded><![CDATA[<p>How to Get the Path to the User desktop in C#.NET ? Here is the single line  Code</p>
<p><span style="color:#0000ff;">string strPath=Environment.GetFolderPath(System.Environ</span></p>
<p><span style="color:#0000ff;">ment.SpecialFolder.DesktopDirectory).ToString();</span></p>
<p>OUTPUT looks like this..</p>
<p><span style="color:#0000ff;">F:\Documents and Settings\Shyju\Desktop</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techiesweb.net/2008/07/get-user-desktop-folder-path-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
