Use corporate library for OLEDB Access database

I want to use the Microsoft Enterprise application suite for MS Access database (OLEDB provider)

I want to use the parameter-based INSERT functionality with the corporate library (just like we do for the SQL provider with parameter-based code - database.params.Add ("@EmpName", this.EmpName);

I want the same for connecting to an MS Access database.

Can someone please let me know How can I do this?

Thanks in advance.

Will this code work?

SirDemon, Thanks for the explanation. I know everything related to INSERT, Update, and Delete for SQL. I want it compatible with MS ACCESS. Ok, tell me, will the code below work?

string query = "INSERT INTO DB (EmployeeID, Name) VALUES (@EmployeeID, @Name)

Database db = DatabaseFactory.CreateDatabase();

DbCommand sqlCommand = db.GetCommandFromText(query);

db.AddInParameter(sqlCommand, "@EmployeeID", this.EmployeeID);
db.AddInParameter(sqlCommand, "@Name", this.Name);

Will this example work in an MS Access database.

+3
1

OleDbCommand , SqlCommand SQL.

OleDbCommand

OleDbCommand

:

string query = "INSERT INTO DB (EmployeeID, Name) VALUES (@EmployeeID, @Name)"

Database db = DatabaseFactory.CreateDatabase();

DbCommand command = db.db.GetSqlStringCommand(query);
db.AddInParameter(command, "@EmployeeID", this.EmployeeID);
db.AddInParameter(command, "@Name", this.Name);
db.ExecuteNonQuery(command);

.

+3

Source: https://habr.com/ru/post/1756504/


All Articles