I'm using DAO to execute SQL statements on an Access database. If I was using VBA, I could use dbFailOnError to throw an error if an update query fails, like so:
function updateTable(db as DAO.Database) as boolean
on error goto errHandler
db.execute "update testTable set name='xyz' where name='abc'",dbFailOnError
updateTable=true
exit function
errhandler:
updateTable=false
on error goto 0
end function
How do I pass dbFailOnError using .NET Interop? It seems that the equivalent would be:
using Dao = Microsoft.Office.Interop.Access.Dao;
namespace DatabaseFunctions
{
public class Updater
{
public bool updateTable(Dao.Database db)
{
try
{
db.Execute("update testTable set name='xyz' where name='abc'",
dbFailOnError);
return true;
}
catch
{
return false;
}
}
}
}
But what namespace do I find dbFailOnError in? It's not in Dao.
dbFailOnError is a member of the DAO enum, RecordsetOptionEnum ... so try DAO.RecordsetOptionEnum.dbFailOnError
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With