datareader.getstring(0) doesn't return the whole string.

J

Jason James

Hi,

I am using an Access DB and a datareader to retrieve a memo field.
When I execute the following code the datareader only ever returns the
first 255 characters, even though I have used a string builder (and a
regular string) which I believe can hold more than 255 characters. Is
there an issue with the datareader or the memo field of an access
database. If I use a dataset and an OleDBDataAdapter then all of the
characters (i.e. > 255) are read in and can be viewed in a datagrid.

Many thanks,

Jason.


Dim cmd As New OleDbCommand("SELECT tblBOMS.bBOM,
Count(tblBOMS.bBOM) AS CountOfbBOM FROM tblBOMS GROUP BY tblBOMS.bBOM
HAVING (((Count(tblBOMS.bBOM))>=2)) ORDER BY Count(tblBOMS.bBOM)
DESC;", cn4)
Dim f As New FileInfo("C:\Duplicate Boms.txt")
Dim s As StreamWriter = f.CreateText()
If cn4.State = ConnectionState.Closed Then
cn4.Open()
End If
Dim dr As OleDbDataReader =
cmd.ExecuteReader(CommandBehavior.Default)
While dr.Read
Dim str As New StringBuilder(dr.GetString(0))


s.WriteLine("=============================================================")
s.WriteLine(str)

s.WriteLine("=============================================================")

' Find all catalogue number with this BOM
Dim dv As New DataView
dv.Table = ds2.Tables("BOMS")
dv.RowFilter = "bBOM like '" & str.ToString() & "'"
Dim drv As DataRowView
For Each drv In dv
Dim strA As String = drv("bName")
s.WriteLine(strA)
Next
End While

s.Close()
s.Dispose()
 

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