Reputation: 287
I am currently saving values to access database and i used Microsoft.Jet.OLEDB.4.0 provider for this and i have configure platform mode from any cpu to x86 in my project in visual studio and it works fine with x86 platform but when i start unit testing using nunit it is not accepting x86 platform and nunit shows error
"UnitTest_Finance.Test.Class1.InsertCashPayment: System.InvalidOperationException : The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine."
now i want alternative way to handle this error while performing unit testing using nunit.
here is my code for reference only
class RepairDLL
{
string dbConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/AutoRepairDB.mdb";
//Method to Booking Value
public virtual bool Insert_Data_Repair_History(EntityClass ec)
{
bool isInsert = false;
//Connect to Database
OleDbConnection connection = new OleDbConnection(dbConn);
connection.Open();
try
{
//Insert Customer Value
string sql = "INSERT into [Repair_History] (FirstName,LastName,City,State,VehicleNo,LienseNo,RepairDate,Summary,Charge) "
+ "VALUES ('" + ec.R_firstName + "','" + ec.R_lastName + "','" + ec.R_city + "','" + ec.R_state + "','" + ec.R_vehicleNo + "','" + ec.R_licenseNo + "','" + ec.R_date + "','" + ec.R_summary + "','" + ec.R_charge + "')";
OleDbCommand command = new OleDbCommand(sql, connection);
command.ExecuteNonQuery();
connection.Close();
isInsert = true;
}
catch
{
throw new Exception();
}
finally
{
// Close the connection
if (connection != null)
{
connection.Close();
}
}
return isInsert;
}
}
Upvotes: 0
Views: 9913
Reputation: 123584
There is no 64-bit version of the Jet database engine, so 64-bit applications will have to use the 64-bit version of the Access Database Engine (ACE), and invoke it like this
Provider=Microsoft.ACE.OLEDB.12.0;
There is also a 32-bit version of the ACE, so applications that use ACE will work in both 32-bit and 64-bit environments. Note also that Jet is deprecated for new applications.
Upvotes: 3