OleDb Truncates Access Memo Field

M

Martin Danner

I'm using the OleDbDataAdapater to Fill a DataSet using MS Access as the
data source. The select command includes a memo field in the result set.
Everything works fine, except only the first 255 characters of the memo
field make it to the DataSet - the rest is truncated.

I tried the same query using an OleDbDatareader with the same result: the
memo field gets truncated at 255 characters.

Can anyone tell me how to retrieve the entire memo field?

Thank you,

Martin Danner
Boise, Idaho
 
R

Rami Saad

Hello,
I tried the lines of code below:
oleDbDataAdapter1.Fill(dataset11.Product);

DataRow row=dataset11.Product.FindByBrandIdModel(1,"TEST");

MessageBox.Show((row["Description_Ext"].ToString().Length).ToString());

"Description_Ext" was of type Memo, and i got 540 characters returned, which
means that dataset can accept more than 255. So the error could be somewhere
else.
Try to check the table properties in the datasource itself
 
P

Paul Clement

¤ I'm using the OleDbDataAdapater to Fill a DataSet using MS Access as the
¤ data source. The select command includes a memo field in the result set.
¤ Everything works fine, except only the first 255 characters of the memo
¤ field make it to the DataSet - the rest is truncated.
¤
¤ I tried the same query using an OleDbDatareader with the same result: the
¤ memo field gets truncated at 255 characters.
¤
¤ Can anyone tell me how to retrieve the entire memo field?
¤

See if the following helps:

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.SequentialAccess)
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 ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top