471,075 Members | 910 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

OleDbDataReader and MS Access Memo Field


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()

Rich

Jul 21 '05 #1
1 6905
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)
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Matt | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.