<?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; ASP.NET</title>
	<atom:link href="http://www.techiesweb.net/category/asp-net/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>How to maintain ASP.NET Connection string in Web.config</title>
		<link>http://www.techiesweb.net/2009/12/maintain-aspnet-connection-string-webconfig/</link>
		<comments>http://www.techiesweb.net/2009/12/maintain-aspnet-connection-string-webconfig/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 10:03:02 +0000</pubDate>
		<dc:creator>Shyju</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.techiesweb.net/?p=57</guid>
		<description><![CDATA[Some time we need to store connection strings in web.config file .The below is the code to add connection string to web.config.file
&#60;configuration&#62; &#60;appSettings&#62; &#60;add key=&#8221;ConnectionString&#8221; value=&#8221;server=localhost;uid=sa;pwd=;database=testdatabase&#8221; /&#62; &#60;/appSettings&#62; &#60;/configuration&#62;
You can change the connection string according to your requirement.here i am specifying a connectionstring for accessing data from the same server (therefor server : localhost) and [...]]]></description>
			<content:encoded><![CDATA[<p>Some time we need to store connection strings in web.config file .The below is the code to add connection string to web.config.file</p>
<p><span style="color: #0000ff;">&lt;configuration&gt; &lt;appSettings&gt; &lt;add key=&#8221;ConnectionString&#8221; value=&#8221;server=localhost;uid=sa;pwd=;database=testdatabase&#8221; /&gt; &lt;/appSettings&gt; &lt;/configuration&gt;</span></p>
<p>You can change the connection string according to your requirement.here i am specifying a connectionstring for accessing data from the same server (therefor server : localhost) and the database name is testdatabase.</p>
<p>How do we access this from our ASP.NET pages ?     This way it is</p>
<p>We need to include System.Configuration namespace<br />
<span style="color: #0000ff;">using System.Configuration;<br />
string connectionString = (string )ConfigurationSettings.AppSettings["ConnectionString"];</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techiesweb.net/2009/12/maintain-aspnet-connection-string-webconfig/feed/</wfw:commentRss>
		<slash:comments>2</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>
	</channel>
</rss>
