acting on bulk execution of SQL statements
An expression . RunSQL (sqlstatement,usetransaction)
an expression. A variable that represents the DoCmd object.
Note: The maximum length of the SQLStatement parameter is 32,768 characters (and the maximum length of the SQL statement action parameter in the Macro window is 256 characters).
The official says it can only be used with Microsoft Access databases, but I'll test Oracle myself.
Example:
///<summary>
///Execute SQL (overloaded parameter IID from long to string)
///</summary>
///<param name= "IID" > Bulk sql Where Condition </param>
///<param name= "sqllist" >list type Sql</param>
///<param Name=" errmsg "> returned result information </param>
// <param name= "Idanew" > Database object </param>
///<returns></ Returns>
public bool Runsqls (string iid, list<string> sqllist, out string errmsg, ref idataaccess IdaN EW)
{
ErrMsg = string. Empty;
bool Breturn = false;
if (sqllist = = NULL | | sqllist.count = = 0)
{
ErrMsg = "[Runsqls ()] parameter [sqllist] is empty, no SQL executable. ";
return false;
}
Db. BeginTransaction ();
String newsql = String. Empty;
Try
{
Loop each SQL in the list
foreach (String sql in Sqllist)
{
if (sql = = string. Empty) continue;
Newsql = SQL;
if (SQL. IndexOf (": IID")! =-1)//If the parameter IID exists
{
Newsql = sql. Replace (": IID", IID.) ToString ());
}
Idanew.runsql (Newsql);//can overload parameter whether error one all rollback do not start transaction separately
Db. Execute (Newsql);
}
//db.completetransaction ();
Breturn = true;
}
catch (Exception e)
{
ErrMsg = E.message;
Commombus.info (e);
//db. Aborttransaction ();
}
return breturn;
}
Use of C # built-in function RunSQL