I tried to created in c# code to export my storeprocedure in excel
SqlConnection cn = new SqlConnection(strConn); cn.Open();
SqlCommand cmd = new SqlCommand("StoreprocedureName", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@date",date);
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.KeyInfo);
i don't know how i export excel.. i have use datatable to export in excelcn.close();
I not too sure about C#, but here is the VBA route that I have used before.
I did google it and I sumbled on this article. As a non-programmer I normally used the TSQL/[OPENROWSET]: http://msdn.microsoft.com/en-us/library/ms190312.aspx
answered Aug 31, 2011 at 11:12 AM