now i get this error , how to rectify this error
code:
else if (extn.Equals(".xls")) { string filePath = Server.MapPath("uploads/" + filename); //string connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';"; // Extra blank space cannot appear in Office 2007 and the last version. And we need to pay attention on semicolon. string connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';"; //Extended Properties='Excel 8.0;HDR=NO;IMEX=1';"; //This connection string is appropriate for Office 2007 and the older version. We can select the most suitable connection string according to Office version or our program. using(OleDbConnection conn = new OleDbConnection(connstring)) { conn.Open(); DataTable sheetsName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[]{null,null,null,"Table"}); //Get All Sheets Name string firstSheetName = sheetsName.Rows[0][2].ToString(); //Get the First Sheet Name string sql = string.Format("SELECT * FROM [$Sheet1],firstSheetName"); //Query String OleDbDataAdapter ada =new OleDbDataAdapter(sql,connstring); DataSet set = new DataSet(); ada.Fill(set); //set.Tables[0]; }
query = @"INSERT INTO Fileupload([category],[subcategory],[uid],[oid],[up_name],[demo1],[keyword],[fdata],[aflag],sizebyte)VALUES(@category,@subcategory,@uid,@oid,@up_name,@demo1,@keyword,@fdata,1,@sizebyte) "; SqlCommand command = new SqlCommand(query, con); //command.CommandText = command.CommandText.ToString(); command.Parameters.AddWithValue("@category", dropcategory.SelectedValue.ToString()); command.Parameters.AddWithValue("@subcategory", DropDownList1.SelectedValue.ToString()); command.Parameters.AddWithValue("@uid", Session["user_id"].ToString()); command.Parameters.AddWithValue("@oid", txtOwnerId.SelectedItem.ToString()); command.Parameters.AddWithValue("@up_name", fname); command.Parameters.AddWithValue("@demo1", demo1.Text); command.Parameters.AddWithValue("@keyword", key); command.Parameters.AddWithValue("@fdata", ); command.Parameters.AddWithValue("@sizebyte", size); command.ExecuteNonQuery(); }