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 !




Data from database into a Excel Sheet


Posted Date: 22 Aug 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms

Posted By: amit chaudhary       Member Level: Silver
Rating:     Points: 8



This code will help us to save our data from database into a Excel Sheet on Our Computer.

First we fetch our data from database table into a grid vire and then we save it into a Excel Sheet.

On page load:-

{
SqlCommand mySqlCommand = new SqlCommand("select * from tbuser", con);
SqlDataAdapter mySqlAdapter = new SqlDataAdapter(mySqlCommand);
DataSet myDataSet = new DataSet();
mySqlAdapter.Fill(myDataSet);
DataTable publishersDataTable = new DataTable("tbuser"); // tbuser is our table name from database
mySqlAdapter.Fill(publishersDataTable);
int dataTableRowCount = publishersDataTable.Rows.Count;
if (dataTableRowCount > 0)
{
GridView1.DataSource = publishersDataTable;
GridView1.DataBind();
}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Data in Excel sheet  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Getting the number of visitors of a website
Previous Resource: Accessing Controls on Master Pages from Content Pages
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference call definitions

Contact Us    Privacy Policy    Terms Of Use