Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read more then 255 characters from MEMO field using ADODB with VB6

Tags:

vb6

ms-access

ado

I am trying to read/write MEMO type field from an Access 2.0 file using ADODB. I can write data into the MEMO field - more than 255 characters (when I open converted file in Access I can see all data that is supposed to be there), but I cannot read more than 255 characters using the VB6 code as bellow. rst("Opis") is the memo field I am interested in:

Set db = New ADODB.Connection
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & T_BAZA & ";Persist Security Info=False"

Set rst = New ADODB.Recordset

SQL = "SELECT DISTINCT Opis FROM JadlospisSzczegoly WHERE Opis IS NOT NULL AND NazwaJadlospisu='" & LCase(Me.Combo3.Text) & "' AND Dzien=" & t_Dzien & " AND Posilek=" & t_Posilek
rst.Open SQL, db, adOpenStatic, adLockOptimistic, adCmdText

Do While Not rst.EOF
    Me.RichTextBox1.Text = Trim$(rst("Opis"))
    rst.MoveNext
Loop

Any ideas on how to solve this problem?

like image 752
bzc0fq Avatar asked Oct 16 '22 09:10

bzc0fq


2 Answers

I have found the issue. DISTINCT in SQL query was the problem. I have read that DISTINCT with memo datatype does not work as it should be.

When I have removed it, all characters from the MEMO filed were displayed.

like image 175
bzc0fq Avatar answered Oct 30 '22 02:10

bzc0fq


Try the GetChunk() method:

Do While Not rst.EOF
    If rst.Fields("Opis").ActualSize > 0 Then
        Me.RichTextBox1.Text = rst.Fields("Opis").GetChunk(rst.fields("Opis").ActualSize)
    Else
        Me.RichTextBox1.Text = "n/a"
    End If
   rst.MoveNext
Loop
like image 23
Hel O'Ween Avatar answered Oct 30 '22 03:10

Hel O'Ween