On Wed, 26 Nov 2003 14:05:54 -0800, "Rich" <rk*@companyabc.com> wrote:
¤
¤ Ok I am trying to read a memo field from an Access DB
¤ that has more than 255 char. I am only getting 255 chars
¤ back from the reader. Why is this and how do i get the
¤ whole memo field. Here is a piece of the code I am using
¤
¤ Do While m_oleDBReader.Read()
¤
¤ var = m_oleDBReader("memo_field")
¤
¤ Loop
¤
¤ m_oleDBReader.Close()
Try the following:
Sub ReadMemoFromAccess()
Dim retVal As Long
Dim FieldLen As Int32
Dim MemoCol As Integer = 1 ' the column # of the Memo field in the query
Dim AccessConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=e:\My Documents\db1.mdb")
Dim AccessCommand As New OleDbCommand("SELECT [record ID], MemoField FROM Table1 WHERE
[record id] = 1", AccessConnection)
AccessConnection.Open()
Dim dr As OleDbDataReader = AccessCommand.ExecuteReader(CommandBehavior.Sequen tialAccess)
dr.Read()
FieldLen = dr.Item(MemoCol).Length
Dim MemoBuffer(FieldLen - 1) As Char
Dim startIndex As Integer = 0
retVal = dr.GetChars(1, startIndex, MemoBuffer, 0, MemoBuffer.Length)
Console.WriteLine(MemoBuffer)
dr.Close()
AccessConnection.Close()
End Sub
Paul ~~~
pc******@ameritech.net
Microsoft MVP (Visual Basic)