Click here to Skip to main content
14,326,294 members
Rate this:
Please Sign up or sign in to vote.
See more:
string MIMEType = MIMEType = "image/doc";

             string DocName = Convert.ToString(DropDownList1.SelectedValue);
             //DropDownList1.SaveAs(Server.MapPath(DocName));
             txtPathName.SaveAs(Server.MapPath(DocName));
             DocName = Server.MapPath(DocName);
             ObjB.DocFile = DropDownList1.SelectedValue.ToString();
             constr = "provider=microsoft.ace.oledb.12.0;data source=" +@DocName + ";extended properties=excel 12.0;";

             OleDbConnection con = new OleDbConnection(constr);
             con.Open();
             //DataTable dtExcelName = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
             DataTable dt1 = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
             string GetExcelSheet = dt1.Rows[0]["Table_Name"].ToString();
             //                string query = "SELECT * FROM [Sheet1$]";
             string query = "Select * from [" + GetExcelSheet + "]";



             OleDbCommand cmd = new OleDbCommand(query, con);
             OleDbDataAdapter da = new OleDbDataAdapter(cmd);
             DataSet ds = new DataSet();

             da.Fill(ds);


What I have tried:

how can i solve this problem .
Posted
Updated 8-Oct-19 4:13am
Comments
phil.o 8-Oct-19 8:32am
   
Please define "not working".
#realJSOP 8-Oct-19 10:08am
   
"not working" = "i'm doing it wrong"

An alternative definition is "what's a debugger?".

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I would start with the debugger. It's included with Visual Studio. You will be AMAZED at what it can do, and you'll be fixing non-working code in nothing flat.

I would start by putting a try/catch block around all the code in the method, and putting a breakpoint in the catch block to see if it's throwing an exception. If it is indeed throwing an exception, the exception it's throwing might tell you what *specifically* is wrong. I'm willing to bet that you won't find the words "it's not working" in the exception.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100