Using ADO to Access a Database from ATEasy

Knowledge Base Article # Q200029

Read Prior Article Read Next Article
Summary Shows example ATEasy code necessary to
  
Login to rate article
Solution:

Note: ATEasy 5.x and above provide a more elaborate example (AdoDb.prj) for accessing database from ATEasy.

The following describes how to access database using ADODB Active Data Objects) ActiveX library:

Add ADO (Active Data Objects) type library to your module libraries (You must have VB or Access installed on your machine).

The following code shows how to open a database for R/W (Declare rs as ADODB.Recordset and sSrc and sCon as String):

rs=CreateObject("ADODB.Recordset")

sSrc="SELECT "+m_sField1+", "+ m_sField2+" FROM "+m_sTableName

sCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+m_sDataBaseFile

rs.Open(sSrc, sCon,,adLockPessimistic)



Notes:

m_sField1 and m_sField2 are database field names
m_sTableName is the database table name that contains m_sField1 and m_sField2
m_sDataBaseFile is the path to the database file.


The following code shows how to read a field in the current record:

rs.Fields.Item(m_sField1).Value



The following code shows how to set a field in the current record, then update the record:

rs.Fields.Item(m_sField1).Value=Value

rs.Update()



The following code shows how to move to the next record:

rs.MoveNext



The following code shows how to close the database connection:

rs.Close()



You can browse on the library object and classes if you need more operations. If you need more help on this select the ADODB library from ATEasy under Libraries and press F1.

Article Date 6/3/2004
Keywords ATEasy, ADO, Database


Login to rate article

Read Prior Article Read Next Article
>