Getting an error while using OracleBulkCopy

Mar 22 2018 1:01 AM
CS0029: Cannot implicitly convert type 'System.Data.OleDb.OleDbTransaction' to 'System.Data.OracleClient.OracleTransaction' is the error which I'm getting in my code.
 
I'm using ASP.NET and C#
 
The aspx code is
  1. private void InsertCSVRecords(DataTable dt)  
  2. {  
  3. conn.Open();  
  4. using (OracleTransaction OracleTransaction =conn.BeginTransaction())  
  5. {  
  6. using (OracleBulkCopy OracleBulkCopy = new OracleBulkCopy(objConnection, OracleBulkCopyOptions.Default, OracleTransaction))  
  7. {  
  8. //assigning Destination table name  
  9. OracleBulkCopy.DestinationTableName = "material_master";  
  10. //Mapping Table column  
  11. OracleTransaction.ColumnMappings.Add("req_no""req_no");  
  12. OracleTransaction.ColumnMappings.Add("req_dt""req_dt");  
  13. OracleTransaction.ColumnMappings.Add("req_by""req_by");  
  14. OracleTransaction.ColumnMappings.Add("mat_desc""mat_desc");  
  15. OracleTransaction.ColumnMappings.Add("mat_type_cd""mat-type_cd");  
  16. OracleTransaction.ColumnMappings.Add("base_uom_cd""base_uom_cd");  
  17. OracleTransaction.ColumnMappings.Add("stor_loc_cd""stor_loc_cd");  
  18. OracleTransaction.ColumnMappings.Add("pur_grp_cd""pur_grp_cd");  
  19. OracleTransaction.ColumnMappings.Add("hsn_cd""hsn_cd");  
  20. OracleTransaction.ColumnMappings.Add("mat_long_desc""mat_long_desc");  
  21. OracleTransaction.ColumnMappings.Add("tax_ind""tax_ind");  
  22. OracleTransaction.ColumnMappings.Add("active_ind""active_ind");  
  23. OracleTransaction.ColumnMappings.Add("del_ind""del_ind");  
  24. //inserting Datatable Records to DataBase  
  25. OracleTransaction.WriteToServer(dt);  
  26. OracleTransaction.Commit();  
  27. conn.Close();  
  28. }  
  29. }  
  30. }  
  31. protected void Import_Click(object sender, EventArgs e)  
  32. {  
  33. try  
  34. {  
  35. //Upload and save the file  
  36. string csvPath = Server.MapPath("~/Uploads/") + Path.GetFileName(FileUpload1.PostedFile.FileName);  
  37. FileUpload1.SaveAs(csvPath);  
  38. if ((FileUpload1.PostedFile != null) && (FileUpload1.PostedFile.ContentLength > 0))  
  39. {  
  40. string fn = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);  
  41. string SaveLocation = Server.MapPath("Uploads") + "\\" + fn;  
  42. FileUpload1.PostedFile.SaveAs(SaveLocation);  
  43. Response.Write("The file has been uploaded.");  
  44. DataTable dt = new DataTable();  
  45. DataSet ds = new DataSet();  
  46. dt.Columns.AddRange(new DataColumn[14] { new DataColumn("req_no"typeof(string)),  
  47. new DataColumn("req_dt"typeof(string)),  
  48. new DataColumn("req_by",typeof(string)),  
  49. new DataColumn("mat_cd"typeof(string)),  
  50. new DataColumn("mat_desc"typeof(string)),  
  51. new DataColumn("mat_type_cd"typeof(string)),  
  52. new DataColumn("base_uom_cd"typeof(string)),  
  53. new DataColumn("stor_loc_cd"typeof(string)),  
  54. new DataColumn("pur_grp_cd"typeof(string)),  
  55. new DataColumn("hsn_cd"typeof(string)),  
  56. new DataColumn("mat_long_desc"typeof(string)),  
  57. new DataColumn("tax_ind"typeof(string)),  
  58. new DataColumn("active_ind"typeof(string)),  
  59. new DataColumn("del_ind"typeof(string))});  
  60. //Read the contents of CSV file.  
  61. string csvData = File.ReadAllText(fn);  
  62. // Execute a loop over the rows.  
  63. foreach (string row in csvData.Split('\n'))  
  64. {  
  65. if (!string.IsNullOrEmpty(row))  
  66. {  
  67. dt.Rows.Add();  
  68. int i = 0;  
  69. //Execute a loop over the columns.  
  70. foreach (string cell in row.Split(','))  
  71. {  
  72. dt.Rows[dt.Rows.Count - 1][i] = cell;  
  73. i++;  
  74. }  
  75. }  
  76. }  
  77. //Bind the DataTable.  
  78. GridView1.DataSource = dt;  
  79. GridView1.DataBind();  
  80. InsertCSVRecords(dt);  
  81. }  
  82. else  
  83. {  
  84. Response.Write("Please select a file to upload.");  
  85. }  
  86. }  
  87. catch (Exception ex)  
  88. {  
  89. Response.Write(ex.Message);  
  90. }  
  91. }