C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Doubt in excelsheet in asp.net


Posted Date: 31 Jul 2008      Total Responses: 2

Posted By: Arun Gandhi       Member Level: Gold     Points: 1



1.How to upload excel sheet?
2.How to retrieve the data in excel sheet with asp.net and how to store the data in sql server 2000.

I am using ASp.net2.0 with C# and Sql server 2000.

Please get me this done.
Give me the sample coding





Responses

Author: VijayaShankar    31 Jul 2008Member Level: GoldRating:     Points: 6

use the following code Snippet for uploading excel through asp.net

if(myFileUpload.HasFile)
{
String name = "PendingReports" + DateTime.Now.ToString().Replace(" ", "") + ".xls";
name = name.Replace("/", "");
name = name.Replace(":", "");
name = Server.MapPath("~/" + name);

try
{


if (!myFileUpload.FileName.EndsWith(".xls"))
{
trErrorMessage.Visible = true;
txtErrorMessage.Text = "Select an Excel file to Upload";

return;
}
else
{
myFileUpload.SaveAs(name);
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + name + @";Extended Properties=""Excel 8.0;HDR=YES;""";
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");
DataTable objDataTable;

using (DbConnection connection = factory.CreateConnection())
{
connection.ConnectionString = connectionString;
try
{
using (DbCommand command = connection.CreateCommand())
{
connection.Open();
command.CommandText = "Select * from [Sheet1$]";
}
}
}
}



Author: Arun Gandhi    31 Jul 2008Member Level: GoldRating:     Points: 1

VijayaShankar where you are saving these data. Can u briefout this.


Post Reply
You must Sign In to post a response.
Next : Once Again Thanks
Previous : google adsense
Return to Discussion Forum
Post New Message
Category: [About DotNetSpider]

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use