Saving a Record

Visual Basic User's Guide > Connecting to Databases

All data access is handled by two Methods, which are SaveToMemory and LoadFromMemory. The SaveToMemory Method stores formatted text to a byte array, which is then passed on to the database engine using Visual Basic's DAO or ADO functions. The following code uses DAO syntax.

[Visual Basic 6]
Private Sub PutRecord()
   Dim ba() As Byte, s As String
   ba = TXTextControl1.SaveToMemory(5, 0)
   ' convert from ANSI to Unicode
   s = StrConv(ba, vbUnicode)
   rs("RTF") = s
End Sub

Other text formats can be used by simply changing the first parameter of the SaveToMemory method.