Partilhar via


Connection Class

Definition

The Connection class establishes a current database session that you can use to execute SQL statements and return results.

public ref class Connection : Microsoft::Dynamics::Ax::Xpp::XppObjectBase
[Microsoft.Dynamics.Ax.Xpp.KernelClass]
public class Connection : Microsoft.Dynamics.Ax.Xpp.XppObjectBase
[<Microsoft.Dynamics.Ax.Xpp.KernelClass>]
type Connection = class
    inherit XppObjectBase
Public Class Connection
Inherits XppObjectBase
Inheritance
Microsoft.Dynamics.AX.KernelInterop.ProxyBase
Connection
Derived
Attributes

Remarks

The following classes extend the Connection class:

  • OdbcConnection
  • OciConnection
  • UserConnection

In the following example, the createStatement method initializes the Statement object. The Statement.executeQuery method executes an SQL statement and then stores the retrieved data in the ResultSet object.

server static void main(Args args) 
{ 
    Connection con = new Connection(); 
    Statement stmt = con.createStatement(); 
    ResultSet r; 
    str sql; 
    SqlStatementExecutePermission perm; 
    sql = strfmt('SELECT VALUE FROM SQLSYSTEMVARIABLES'); 
    // Set code access permission to help protect the use of 
    // Statement.executeUpdate. 
    perm = new SqlStatementExecutePermission(sql); 
    perm.assert(); 
    try 
    { 
        r = stmt.executeQuery(sql); 
        while (r.next()) 
        { 
            print r.getString(1); 
            pause; 
        } 
    } 
    catch (exception::Error) 
    { 
        print "An error occurred in the query."; 
        pause; 
    } 
    // Code access permission scope ends here. 
    CodeAccessPermission::revertAssert(); 
}

Constructors

Connection()
Connection(IntPtr)

Fields

kernelClass (Inherited from XppObjectBase)

Methods

__shouldCallNew(Type)
addXppProxyReference(Type, Object) (Inherited from XppObjectBase)
Call(String, Object[], Type[], Object[]) (Inherited from XppObjectBase)
cancelTimeOut(Int32) (Inherited from XppObjectBase)
createKernelClass(Object[], Type[], Object[]) (Inherited from XppObjectBase)
createStatement()

Creates a Statement object that is used to execute an SQL statement.

createStatement(ResultSetType, ResultSetConcurrency)
createStatement(ResultSetType)
equal(XppObjectBase) (Inherited from XppObjectBase)
finalize()
GetIntPtr()
GetKernelInstanceUniqueId() (Inherited from XppObjectBase)
getTimeOutTimerHandle() (Inherited from XppObjectBase)
getXppProxyReference(Type) (Inherited from XppObjectBase)
handle()
isInTransactionScope()
IsManagedValid()
kernelhandle()
KernelInstanceDisposed() (Inherited from XppObjectBase)
MakeReflectionCall(String, Object[]) (Inherited from XppObjectBase)
newmethod()

Initializes a new instance of the Connection class.

notify() (Inherited from XppObjectBase)
notifyAll() (Inherited from XppObjectBase)
objectOnServer()
Obsolete.
(Inherited from XppObjectBase)
odbcGetInfoInt(Int32)

Provides an interface to the SQLGetInfo Open Database Connectivity (ODBC) function to retrieve information about the ODBC driver and data source that are associated with a connection.

odbcGetInfoLong(Int32)

Provides an interface to the SQLGetInfo ODBC function to retrieve information about the ODBC driver and data source that are associated with a connection.

odbcGetInfoStr(Int32)

Provides an interface to the SQLGetInfo ODBC function to retrieve information, in string format, about the ODBC driver and data source that are associated with a connection.

setTimeOut(String, Int32, Boolean)
Obsolete.
(Inherited from XppObjectBase)
setTimeOut(String, Int32)
Obsolete.
(Inherited from XppObjectBase)
ToString()

Converts the Connection object to a string.

transactionScopeAbort()
transactionScopeBegin()
transactionScopeCommit()
ttsabort()

Discards changes that are associated with a transaction and rolls the database back to the original state.

ttsbegin()

Begins a transaction.

ttscommit()

Commits the changes that are associated with a transaction to the database.

ttsLevel()

Returns the number for the last call to the ttsbegin method that is used to begin a transaction.

ttsNotifyAbort()

Is called when an exception is thrown.

ttsNotifyBegin()
ttsNotifyCommit()

Is called when the ttscommit method is called.

usageCount() (Inherited from XppObjectBase)
VerifyKernelClass() (Inherited from XppObjectBase)
wait() (Inherited from XppObjectBase)
Xml() (Inherited from XppObjectBase)
Xml(Int32) (Inherited from XppObjectBase)

Applies to