Microsoft Office Tutorials and References
In Depth Information
Creating a Contacts Database
' * * * * *¶
Private Sub CreateTable(objConn As Object)¶
'ADODB Command Object declaration¶
Dim objCmd As Object¶
'Create ADODB Command object to execute SQL command¶
Set objCmd = CreateObject("ADODB.Command")¶
'ADODB Command object needs to know the Connection¶
'object that it is working with¶
Set objCmd.ActiveConnection = objConn¶
'Create table by using Outlook Contact fields names¶
'Set SQL string to execute with ADODB Command object¶
objCmd.CommandText = "CREATE TABLE " & tblName & _¶
"([EntryID] STRING(255) PRIMARY KEY," & _¶
"[FullName] STRING(255)," & _¶
"[Email1Address] STRING(255)," & _¶
"[Email2Address] STRING(255)," & _¶
"[Email3Address] STRING(255)," & _¶
"[WebPage] STRING(255)," & _¶
"[BusinessPhone] STRING(255)," & _¶
"[BusinessFax] STRING(255)," & _¶
"[HomePhone] STRING(255)," & _¶
"[MobilePhone] STRING(255)," & _¶
"[PagerNumber] STRING(255)," & _¶
"[Address] STRING(255)," & _¶
"[AddressCity] STRING(255)," & _¶
"[AddressCountry] STRING(255)," & _¶
"[AddressPostalCode] STRING(255)," & _¶
"[AddressPostOfficeBox] STRING(255)," & _¶
"[AddressState] STRING(255)," & _¶
"[AddressStreet] STRING(255)," & _¶
"[Categories] STRING(255))"¶
'Execute ADODB Command object¶
'Similar to running a query in Access¶
'adCmdText = 1 to evaluate command text as SQL statement¶
objCmd.Execute , , 1¶
'Release object variables and free memory¶
Set objCmd = Nothing¶
End Sub¶
' * * * * *¶
Private Sub SaveData(objContact As Object, objConn As Object)¶
'ADODB Recordset Object declaration¶
Dim objRs As Object¶
'Create ADODB Recordset object¶
Set objRs = CreateObject("ADODB.Recordset")¶
'Open recordset by using SELECT statement of SQL¶
'in requested connection¶
objRs.Open "SELECT * " & _¶
"FROM " & tblName & _¶
" WHERE EntryID=" & Chr(34) & _¶
objContact.EntryID & Chr(34), objConn, 2, 3¶
With objRs¶
Out
Search JabSto ::




Custom Search