troubleshooting Question

How to export the result set of a SQL Server stored procedure to an Excel spreadsheet using VS2005 for a windows application?

Avatar of zimmer9
zimmer9Flag for United States of America asked on
.NET ProgrammingC#
4 Comments2 Solutions393 ViewsLast Modified:
I am writing a C# windows application using VS2005. Do you know how I could rewrite the following routine to export the result of calling a SQL Server stored procedure to an Excel spreadsheet (Excel 2003).

private void FallQueryACSToExcel(string reportyr)
            SqlConnection _conn = new System.Data.SqlClient.SqlConnection("Data Source=;");
            System.Data.SqlClient.SqlCommand comm = _conn.CreateCommand();
            comm.CommandType = System.Data.CommandType.StoredProcedure;
            comm.CommandText = string.Format("procFlACSExclAAA");
            comm.Parameters.Add("@RptYear", SqlDbType.VarChar, 50).Value = reportyr;
            comm.CommandTimeout = 750;
            System.Data.DataSet dataSet1 = new System.Data.DataSet();
            System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter(comm);
Anuradha Goli
Anuradha Goli (anuradhay)

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros