Posted on: 10/14/2014 3:40:06 PM | Views : 605

Hi,
I have implemented a code to copy the excel sheet to a sql table, but it is giving me error like this.
WriteToServer requires an open and available Connection. The connection's current state is closed. Please see the code for your reference:-
private void ImporttoSQL(string sPath) { // Connect to Excel 2007 earlier version //string sSourceConstr = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\AgentList.xls; Extended Properties=""Excel 8.0;HDR=YES;"""; // Connect to Excel 2007 (and later) files with the Xlsx file extension string sSourceConstr1 = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\AgentList.xls; Extended Properties=""Excel 8.0;HDR=YES;"""; string sSourceConstr = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=Y ...

Go to the complete details ...