Inserts one new row into a database table. (This function is equivalent to a SQL INSERT statement.)

Function Group Execution Windows Embedded Thin Client
DBInsert Database/ERP Synchronous Supported Supported Supported
Note: This feature emulates SQL (Structured Query Language) database operations. You should be familiar with how SQL commands are formed and executed before you use this feature.


DBInsert( strDBConn, strTable, strValues, optStrColumns, "optStrErrorTag" )
The name of the database connection. Connections are configured in the Database/ERP folder in the Project Explorer.
The name of the table in the database.
A string that lists the values to be written in the new row. This list of values should be comma-delimited, and string values must be enclosed in single quotes.
A string that lists the columns into which the values will be written. This list of column names should be comma-delimited and in the same order as the values specified by strValues.

This is an optional parameter. If no columns are specified, then the values will be written in the default column order of the database table.

The name of a String tag that will receive detailed error messages, if errors occur during runtime.
Note: The tag name must be enclosed in quotes, as shown in the syntax diagram, or else the project will try to get the value of the named tag.

This is an optional parameter.

Returned value

In case of error, returns a negative number. Otherwise, returns 1.


As used in a Math worksheet:
Tag Name Expression
nErrorCode DBInsert( "DB1", "Table1", "1, 'one'", "Column1, Column2" )