first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

VB: ADO; Code; Reading and Writing Strings to a DAO Table

Public Function basGetString(KeyName As String, ColumnName As String) As String

On Error GoTo basGetString_Err

Set m_rsADO = New ADODB.Recordset
m_rsADO.Open Source:="tblStrings", _
    ActiveConnection:=m_cnnADO, _
    CursorType:=adOpenKeyset, _
    LockType:=adLockReadOnly, _
    Options:=adCmdTable

With m_rsADO
    .Find Criteria:="name = '" & KeyName & "'", _
        SearchDirection:=adSearchForward
    If Not .EOF Then _
        basGetString = .Fields(ColumnName) & Empty
End With

basGetString_Exit: m_rsADO.Close Set m_rsADO = Nothing Exit Function

basGetString_Err: Select Case Err Case Else MsgBox Err & ": " & Err.Description, vbCritical, "basGetString Error" Resume basGetString_Exit End Select

End Function

Public Sub basWriteString(KeyName As String, NewStr As String)

Dim strSQL As String

On Error GoTo basWriteString_Err

strSQL = "UPDATE tblStrings SET tblStrings.string = """ & NewStr & """" _
    & " WHERE tblStrings.name = """ & KeyName & """"

Set m_cmdADO = New ADODB.Command

With m_cmdADO
    .ActiveConnection = m_cnnADO
    .CommandType = adCmdText
    .CommandText = strSQL
    .Execute
End With

basWriteString_Exit: Set m_cmdADO = Nothing Exit Sub

basWriteString_Err: Select Case Err Case Else MsgBox Err & ": " & Err.Description, vbCritical, "basWriteString Error" Resume basWriteString_Exit End Select

End Sub

mod date: 1999-03-01T21:35:47.000Z