One moment please...
 
 
Exact Synergy Enterprise   
 

Exact Synergy Enterprise Class Reference: EDLConnection

On this page

1.Description
2.Member
 

 

Class name:   EDLConnection
Namespace:   Exact.Data
Assembly:   Exact.Data.dll

Description
Description: Encapsulates all data access for Exact Synergy Enterprise applications, and makes it possible to retrieve or update SQL data with a minimum of code. Hides all differences between SQL Server and Oracle.

Members

Name Type Description
ApplicationName Read-write property: String The application name set on the database connection. This can be seen in the SQL Server Profiler. By default this is "Exact Synergy Enterprise" for Exact Synergy Enterprise Web application.
Close Sub Closes the database connection
Connect(Server As String, Database As String, Optional UserName As String = "", Optional Password As String = "", Optional Options As EDLConnectionOptions = 0) Sub Establishes the database connection. If the UserName argument is empty, as integrated-security connection is established.
If Options = EDLConnectionOptions.NoPooling, connection pooling is disabled.
Enlisting in distributed transactions is always disabled.
CreateTransaction(Optional IsolationLevel = IsolationLevel.ReadUncommitted) Function: EDLTransaction Creates a transaction object, to include multiple SQL statements in a single transaction.

When multiple transaction objects are created, the real database transaction will only be committed when the last EDLTransaction object is committed. However, when one EDLTransaction object is rolled back, the database transaction is always rolled back immediately, even if there are other open EDLTransaction objects.

Database Read-only property: String The name of the database
DBMS Read-write property: DBMS enum Returns the database system of the current connection:
  • DBMS.SQLServer
  • DBMS.Oracle
  • DBMS.Pervasive
  • DBMs.MySQL 
Exec(SQL As String, Optional Params As Object = Nothing, Optional Options As EDLQueryOptions = 0, Optional ParamNames As Object = Nothing, Optional QueryTimeout As Integer = -1) Function: Integer Executes an SQL statement, and returns the number of rows affected.

For use of parameters in the query, see the Query function.

The QueryTimeout is the number of seconds after which the function will throw an EDLTimeoutException error. The default value is 30 seconds.

Example:

conn.Exec("UPDATE humres SET comp = @P1 " & _
                        "WHERE comp = @P2 AND costcenter = @P3", _
                        New String() {"001", "002", "R&D"})
Insert(Table As String, Columns() As String, Values() As Object) Function: Integer Builds and executes a parametrized INSERT statement.
The Columns argument contains an array of column names.
The Values argument contains an array of values to be inserted, matching the column names in the Columns argument. To insert the value of a SQL function, use "New SQLFunction(Functionname)" as one of the values in the Values array.

Example:

conn.Insert("Items", _
                        New String() {"Code", "Description", "syscreated"}, _
                        New Object() {"ABC", "Letter board", _
                        New SQLFunction("GETDATE()")})
                        
LastAutoIncrementValue(Table as String) Function: Integer Returns the last-allocated auto-increment value for the specified table.
Literal(Value as Object) Function: String Returns a string that can be used directly in an SQL query.
If an array, or an object that support the ICollection interface, is passed, a comma-separated list of literal values is returned that can be used in an IN clause.
Merge(Table As String, Key As Object, KeyValue As Object, Columns As Object, ColumnValues As Object) Sub Construct and executes an SQL statement that, in a single statement, inserts or updates a records, based on the existence of the specified Key value.

All arguments (except Table) can either be a single value or an array of values, but the "values" must match dimension with the "names". E.g., if the Key argument is a single string, then the KeyValue argument must be a single value. If the Columns argument is an array of strings, the ColumnValues must be an array of values with exactly the same upper bound.

Example:

 conn.Merge("Resources", "HID", 847, _
                          New String() {"ID", "FullName", "UserName"}, _
                          New Object() {New SQLFunction("NEWID()"), _
                        "Sebastian Toet", "toet0845-6"})
Prepare(SQL As String, DataTypes As Object, Optional Options As EDLQueryOptions = 0, Optional ParamNames As Object = Nothing, Optional QueryTimeout As Integer = -1) Function: EDLPreparedQuery Returns an EDLPreparedQuery object that can be used to execute the same parametrized query or statement multiple times with different parameters.

For use of parameters see the Query function.

The DataTypes argument should contain the data types of the query parameters.

Example:

Dim qu As EDLPreparedQuery = _
                        conn.Prepare("SELECT fullname FROM humres WHERE res_id=@P1", _
                        EDLDataTypes.Int, EDLQueryOptions.SingleValue)
                        Dim name As String
                        name  = qu.Query(310)
                        name = qu.Query(845)
                        name = qu.Query(994)
qu = conn.Prepare("DELETE FROM humres WHERE res_id = @P1", _
                        EDLDataTypes.Int)
                        qu.Exec(845)
                        qu.Exec(1024)
Query(SQL As String, Optional Params As Object = Nothing, Optional Options As EDLQueryOptions = 0, Optional ParamNames As Object = Nothing, Optional QueryTimeout As Integer = -1) Function: Object Returns the result of an SQL Query, as:
  1. By default as a 2-dimensional array, if no options are supplied.
  2. A 1-dimensional array if EDLQueryOptions.SingleRow is supplied.
  3. A single value if EDLQueryOptions.SingleValue is supplied
  4. An array of arrays if EDLQueryOptions.MultipleResultsets is supplied
  5. An object set to "Nothing" if there are no query results
  6. An IDataReader interface if EDLQueryOptions.ReturnDataReader is supplied. The calling application must close this object, before any other query is performed.
  7. By default all database Null values are translated to Nothing values. Only of the EdlQueryOptions.Nulls is supplied the Null values are retained.

Parametrized queries must use the following paremeter names in the SQL query (no question marks):

  • The parameter names @P1, @P2, etc, in the order of the parameters supplied to the Query method
  • Parameter names that are supplied in the ParamNames argument

Example:

Dim data(,) As Object = conn.Query( _
                        "SELECT ID, syscreated, Description " & _
                        "FROM Absences " & _
                        "WHERE Type = @P1 AND EmpID = @P2 " & _
                        "ORDER BY syscreated DESC", _
                        New Integer() {0, 845})

Stored procedures can be called as:

  • Supply only the name of the stored procedure
  • Supply the EDLQueryOptions.StoredProcedure options
  • Supply the names of the arguments of the stored procedure as a string array to the ParamNames argument

Example:

Dim bManager As Boolean = _
                        conn.Query("IsIndirectManager", _
                        New Integer() {empid, hrid, 0}, _
                        EDLQueryOptions.StoredProcedure Or _
                        EDLQueryOptions.SingleValue, _
                        NewString() {"@empid", "@manid", "@amount"}) <> 0
Rollback Sub Rolls back all outstanding transactions on this connection
Server Read-only property: String The name of the database server
ToString Function: String Returns a string containingtheserveranddatabasenameas"Server=xxx;Database=yyy", overrides the ToString of the Object base class.

     
 Main Category: Support Product Know How  Document Type: Online help main
 Category: SDK  Security  level: All - 0
 Sub category: General  Document ID: 09.454.434
 Assortment:  Date: 19-05-2018
 Release:  Attachment:
 Disclaimer