usando ado

Upload: tiago-andrade

Post on 07-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/4/2019 Usando ADO

    1/2

    When I started to develop applications with MS-SQL Server all other middleware

    seamed ineffective to provide me the needed feedback for production boost.

    So I took a chance with ADO and it did not disappoint me.

    I strongly recommend that all users pretending to build applications with any data-

    access engine (ADO, dbExpres, ...) to use Borland DataSnap/MIDAS components to

    make the application two or three tired, believe me this will help a lot in a lot of aspectsthat I'll describe on my articles involving this subject.

    As for a start you should build a good Connection String. Prefer to use Windows

    Authentication as it is more secure, scalable and easier way to grant access to the

    database. Make it clear witch server you will use and witch will be the default database.

    Passed that stage, configure the following properties of TADOConnection as follows:

    - CursorLocation: clUseServer

    *** Server Cursors demand least resources from the db

    - IsolationLevel: ilCursorStability- KeepConnection: False

    *** Trust me, it's absolutely unnecessary to keep a connection, all datasets will

    automatically start a new connection when necessary. Only keep connections if you

    really need info from the current connection that can't be restored lately.

    - LoginPrompt : False

    *** This works in parallel with the Windows Authentication recommendation for the

    Connection String.

    Use TADODataSet component to access all db objects, it's the best option due its

    flexibility. It may prove to be a little bit more arduous to work with it rather then

    TADOQuery but it's more reliable and flexible.

    Configure all TADODataSets as it follows:

    - LockType: ltReadOnly

    *** This will NOT prevent you from uploading data because Midas use SQL DML

    instructions (INSER, UPDATE, DELETE) to do that, not cursors.

    - CursorType: ctForwardOnly

    *** Remember that Midas main goal is to work with unidirectional cursors to improve

    db performance by making data caching on local memory.

    - CursorLocation: clUseServer*** Explained above

    - CommandText: Try to optimize SELECT instructions by using with a filter condition

    and also fetching only the needed fields. E.g.:

    SELECT * FROM TABLE WHERE PK = :APARAM

    *** Fetching all fields to make data-entry available.

    SELECT PK, SEARCH_FIELD FROM TABLE WHERE SEARCH_FIELD LIKE

    :APARAM

    *** Fetching only needed fields to obtain the desired record. After obtaining this record,

    pass it as the value for filtering param on the main query.

    I don't know of ADO full capabilities, but on an environment of 500 to 1000 users it'sworking just fine.

  • 8/4/2019 Usando ADO

    2/2

    I'll post an article stating best usage of Master/Detail relations using Midas very soon on

    Midas category articles.

    "All you need to see all hope perish is to stand still and do nothing"