Bharathi Raja

Bharathi Raja

  • NA
  • 1.1k
  • 51.6k

The Microsoft Jet database engine could not find the object

May 2 2018 5:09 AM
The Microsoft Jet database engine could not find the object 'test'. Make sure the object exists and that you spell its name and the path name correctly.
  1. if (txtFileName.Text != "")  
  2. {  
  3.     //string path = @"‪D:\BARATHIRAJA\SUPER MARKET\GST\stock management\bin\Debug\add_product.csv";  
  4.     string path = txtFileName.Text;  
  5.     string id = "";  
  6.     string pimage = "";  
  7.     string cate = "";  
  8.     string subcat = "";  
  9.     string pcode = "";  
  10.     string peng = "";  
  11.     string ptam = "";  
  12.     string barcode = "";  
  13.     string unit = "";  
  14.     string promrp = "";  
  15.     string procast = "";  
  16.     string pprice = "";  
  17.     string aqty = "";  
  18.     string alertqty = "";  
  19.     string pdetail = "";  
  20.     string tax = "";  
  21.     string mdate = "";  
  22.     string edate = "";  
  23.      
  24.         OleDbConnection my_con = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;" +  
  25.               "Data Source=" + Application.StartupPath + "\\test.xls;" +  
  26.               "Extended Properties=Excel 8.0");  
  27.   
  28.            my_con.Open();  
  29.     //    OleDbCommand icmd = new OleDbCommand("select  [id],[product_image],[category],[sub_category],[product_code],[product_english],[product_tamil],[barcode],[unit],[product_mrp],[product_cost],[product_price],[available_quantity],[alert_quantity],[product_detail],[tax],[man_date],[exp_date] from ["+my_con+"]", my_con);  
  30.           OleDbCommand icmd = new OleDbCommand("select * from [test] ", my_con);  
  31.   //this line eroor Throw 
  32.         OleDbDataReader dr = icmd.ExecuteReader();  
  33.         while (dr.Read())  
  34.         {  
  35.             id = dr[0].ToString();  
  36.             pimage = dr[1].ToString();  
  37.             cate = dr[2].ToString();  
  38.             subcat = dr[3].ToString();  
  39.             pcode = dr[4].ToString();  
  40.             peng = dr[5].ToString();  
  41.             ptam = dr[6].ToString();  
  42.             barcode = dr[7].ToString();  
  43.             unit = dr[8].ToString();  
  44.             promrp = dr[9].ToString();  
  45.             procast = dr[10].ToString();  
  46.             pprice = dr[11].ToString();  
  47.             aqty = dr[12].ToString();  
  48.             alertqty = dr[13].ToString();  
  49.             pdetail = dr[14].ToString();  
  50.             tax = dr[15].ToString();  
  51.             mdate = dr[16].ToString();  
  52.             edate = dr[17].ToString();  
  53.   
  54.             MySqlConnection con = new MySqlConnection("SERVER=localhost;" +  
  55.                 "DATABASE=shop_management;" +  
  56.                 "UID=root;" +  
  57.                 "PASSWORD=;");  
  58.             con.Open();  
  59.   
  60.             MySqlCommand icmmd = new MySqlCommand("INSERT INTO add_product(id,product_image,category,sub_category,product_code,product_english, product_tamil,  barcode,unit,product_mrp,product_cost,product_price,available_quantity,alert_quantity,product_detail,tax,man_date,exp_date)VALUES(@a,@b,@c,@d,@e,@f,@g,@h,@i,@j,@k,@l,@m,@n,@o,@p,@q,@r)", con);  
  61.             icmmd.Parameters.AddWithValue("a", id);  
  62.             icmmd.Parameters.AddWithValue("b", pimage);  
  63.             icmmd.Parameters.AddWithValue("c", cate);  
  64.             icmmd.Parameters.AddWithValue("d", subcat);  
  65.             icmmd.Parameters.AddWithValue("e", pcode);  
  66.             icmmd.Parameters.AddWithValue("f", peng);  
  67.             icmmd.Parameters.AddWithValue("g", ptam);  
  68.             icmmd.Parameters.AddWithValue("h", barcode);  
  69.             icmmd.Parameters.AddWithValue("i", unit);  
  70.             icmmd.Parameters.AddWithValue("j", promrp);  
  71.             icmmd.Parameters.AddWithValue("k", procast);  
  72.             icmmd.Parameters.AddWithValue("l", pprice);  
  73.             icmmd.Parameters.AddWithValue("m", aqty);  
  74.             icmmd.Parameters.AddWithValue("n", alertqty);  
  75.             icmmd.Parameters.AddWithValue("o", pdetail);  
  76.             icmmd.Parameters.AddWithValue("p", tax);  
  77.             icmmd.Parameters.AddWithValue("q", mdate);  
  78.             icmmd.Parameters.AddWithValue("r", edate);  
  79.             icmmd.ExecuteNonQuery();  
  80.             con.Close();  
  81.         }  
  82.      
  83.     MessageBox.Show("data Imported");  
  84.     txtFileName.Text = "";  
  85.       
  86.   
  87. }  

Answers (2)