/ Forums / Advansys Formativ / Creating Solutions with Formativ / Access Database / Reply To: Access Database
September 21, 2003 at 4:45 pm
#6714
You need to have database access services installed on your PC regardless of whether you are using Formativ or any other development tool. The only example I have is where we use Microsoft’s ADO (Active Data Objects) to access a JET (Access) database:
sub UpdateAcceptedSupportIssue(iMsg, iEvent, iEngineer)
dim iADOObj
dim iRST
' create a new instance of an ADO Connection object
set iADOObj = CreateObject("ADODB.Connection")
' Did we get a handle to the ADO connection
if not isobject(iADOObj) then
call msgbox("Failed to create ADODB.Connection object.", vbCritical, "Support Example")
else
' open the test data source with the Connection object
iConnnectString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & SUPPORT_DATABASE
iADOObj.Open iConnnectString
' Are we connected to the database?
if err.number = 0 then
' Connected to the database - what do we want to do? We currently support
' accepting a new support incident, and completing (closing) an incident.
select case iEvent
' Accept - Add a new record the SQL database
case "GW#C#ACCEPT"
iSQLString = "INSERT INTO Support(Incident,RequestedBy,Subject,ResponsibleEngineer,RequestedDate) VALUES ('"& iMsg.MessageID &"','"& iMsg.FromText& "','"& iMsg.Subject&"','" & iEngineer & "','"&SQLDate(Date)&"')"
iADOObj.Execute(iSQLString)
' Complete (close) - Update the existing record in the SQL database
case "GW#C#COMPLETE"
iSQLString = "UPDATE Support SET CompletedDate='" & SQLDate(Date + 5) & "' WHERE Incident='" & iMsg.MessageID &"'"
iADOObj.Execute(iSQLString)
end select
' close and remove the Recordset object from memory
iRST.Close
set iRST = Nothing
else
msgbox err.description, vbCritical, IDS_CAPTION
end if
' Close and remove the Connection object from memory
iADOObj.Close
end if
set iADOObj = Nothing
end sub
You can learn more about ADO from this link to Microsoft’s web site.
I hope this helps.
Advansys Support