The Execute Method of the ODAX ActiveX Object performs INSERT, UPDATE and DELETE statements on the specified .XML or .CSV file.
Execute (Method of the ODAX ActiveX Object) Syntax var count = object.Execute(sql_statement, format, delimiter, firstrow)
Parameters
Items listed in this section indicate parameters, or attributes which can be set.
Name Possible Values Description
Default Value Sql_statement String String representing the INSERT, UPDATE and DELETE SQL statement to be executed N/A Format 0 or 1 If no extension is supplied the format parameter is used to determine file format (0 = XML, 1 = CSV) N/A Delimiter String Delimiter which is used in CSV files as a column separator. Even though there is no special use for this in XML files you cannot leave this blank, hence you need to provide a valid value N/A FirstRow True or False This denotes that the first row of a CSV file contain the Column Names. If set to false in CSV mode it will retrieve columns as column1, column2 etc N/A
Return Values
Name Description Count Returns 0 if no record were updated/deleted/inserted or returns the number of record affected by the operation. (Please Refer Error Codes for More Detail)
Examples
The following example inserts records to a XML file:
<script> var ax = new ActiveXObject("CeODAX.ODAX"); var FieldValue1 = 'Red'; var FieldValue2 = Green'; var FieldValue3 = 'Blue'; var QueryString = 'INSERT INTO \'\\application\\test.xml\' (field1,field2,field3) VALUES ('; QueryString += '\''+FieldValue1+'\','; QueryString += '\''+FieldValue2+'\','; QueryString += '\''+FieldValue3+'\');'; var count = ax.Execute(QueryString,0,',',false); </script>
Copy example to clipboard The following example inserts records to a CSV file:
<script> var ax = new ActiveXObject("CeODAX.ODAX"); var QueryString = 'INSERT INTO \'\\application\\test.csv\' (field1,field2,field3) VALUES ('; QueryString += '\''+FieldValue1+'\','; QueryString += '\''+FieldValue2+'\','; QueryString += '\''+FieldValue3+'\');'; var count = ax.Execute(QueryString,1,',',true); </script>
Copy example to clipboard The following example updates records in a XML file
<script> var ax = new ActiveXObject("CeODAX.ODAX"); var fieldValue = 'Orange'; var conditionField = 'Red'; var QueryString = 'UPDATE \'\\application\\test.xml\' SET field1='; QueryString += '\''+ fieldValue +'\''; QueryString += ' WHERE field1=\''; QueryString += conditionField +"\';" var count = ax.Execute(QueryString,0,',',false); </script>
Copy example to clipboard The following example deletes records in a XML file
<script> var ax = new ActiveXObject("CeODAX.ODAX"); var conditionField = 'Red'; var QueryString = 'DELETE FROM \'\\application\\test.xml\' WHERE field1='; QueryString += '\''+ conditionField +'\';'; var count = ax.Execute(QueryString,0,',',false); </script>
Copy example to clipboard
Remarks
GeneralThe delimiter and firstrow are a Select. If firstrow is set to true when creating a table with INSERT, then the field names are written to the first row as column names.Query needed after ExecuteThe current result set becomes invalid after any Execute (INSERT, UPDATE, DELETE) and arbitrary values will be returned by MoveFirst etc. A new SELECT query must be performed to get valid results.
Additional Information
Supported Platforms Windows Mobile, Windows CE Persistence Runs immediately. Min. Requirements None.