Hi there!
When the Memo field of a Access Database is over 255 characters,
OleDbDataAdapter doesn't
fill well my DataTable (only the first 255 characters). I tried with
OleDbDataReader, GetChars and filling a StringBuilder, and it seems it
only has 255 characters; it doesn't reach the rest.

Please help!

oliver

Re: Problem with Access-MemoField that contains Data > 255 characters by Grzegorz

Grzegorz
Mon Nov 15 07:41:16 CST 2004

U¿ytkownik "Oliver Krüger" <oliverk@datadesign.de> napisa³ w wiadomo¶ci
news:eVWWI6wyEHA.2804@TK2MSFTNGP15.phx.gbl...
> Hi there!
> When the Memo field of a Access Database is over 255 characters,
> OleDbDataAdapter doesn't
> fill well my DataTable (only the first 255 characters). I tried with
> OleDbDataReader, GetChars and filling a StringBuilder, and it seems it
> only has 255 characters; it doesn't reach the rest.
>


You have an error. In what way do you check string lenght? I have made small
snipped and it works ok:

using System;
using System.Data.OleDb;

namespace TestAccessMemo
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Test t = new Test();
t.ReadD();

System.Console.ReadLine();
}
}

class Test
{
OleDbConnection con = new OleDbConnection();
public Test()
{
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data Source=E:\NoteDb.mdb";
}

public void ReadD()
{
OleDbCommand myC = new OleDbCommand("Select Notes From tblData");
myC.Connection = con;
con.Open();
OleDbDataReader dr = myC.ExecuteReader();
while(dr.Read())
{
string note = dr.GetString(0);
System.Console.WriteLine("Note in db: \n{0},\n{1} chars",
note, note.Length);
}
con.Close();
}
}
}

Regards,
Grzegorz


Re: Problem with Access-MemoField that contains Data > 255 characters by Oliver

Oliver
Mon Nov 15 08:53:27 CST 2004


"Grzegorz Danowski" <gdn@usuntopoczta.onet.pl> wrote in message
news:cnabm2$8o2$1@inews.gazeta.pl...
> U¿ytkownik "Oliver Krüger" <oliverk@datadesign.de> napisa³ w wiadomo¶ci
> news:eVWWI6wyEHA.2804@TK2MSFTNGP15.phx.gbl...
>> Hi there!
>> When the Memo field of a Access Database is over 255 characters,
>> OleDbDataAdapter doesn't
>> fill well my DataTable (only the first 255 characters). I tried with
>> OleDbDataReader, GetChars and filling a StringBuilder, and it seems it
>> only has 255 characters; it doesn't reach the rest.
>>
>
>
> You have an error. In what way do you check string lenght? I have made
> small snipped and it works ok:
>
> using System;
> using System.Data.OleDb;
>
> namespace TestAccessMemo
> {
> class Class1
> {
> [STAThread]
> static void Main(string[] args)
> {
> Test t = new Test();
> t.ReadD();
>
> System.Console.ReadLine();
> }
> }
>
> class Test
> {
> OleDbConnection con = new OleDbConnection();
> public Test()
> {
> con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
> @"Data Source=E:\NoteDb.mdb";
> }
>
> public void ReadD()
> {
> OleDbCommand myC = new OleDbCommand("Select Notes From tblData");
> myC.Connection = con;
> con.Open();
> OleDbDataReader dr = myC.ExecuteReader();
> while(dr.Read())
> {
> string note = dr.GetString(0);
> System.Console.WriteLine("Note in db: \n{0},\n{1} chars",
> note, note.Length);
> }
> con.Close();
> }
> }
> }
>
> Regards,
> Grzegorz

Hi Grzegorz
Thanks for your fast reply!!!

For my solution I use a DataAdapter :

internal void SQLQueryRead(string p_sSql, ref DataTable p_Data)
{
string sPath = @"database\ckdata.mdb";
string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Persist
Security Info=False;Data Source=" + sPath;

OleDbConnection oleDbConnection = new
OleDbConnection(sConnectionString);
OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(p_sSql,
oleDbConnection);
oleDbDataAdapter.Fill(p_Data);
oleDbConnection.Close();

//Only for testing
//The MemoCommon-Field contains a text string with 500 characters
//The Console.WriteLine() output is 255 :-(
try{
string myString = p_Data.Rows[0]["MemoCommon"].ToString();
Console.WriteLine(myString.Length.ToString());
}
catch{}
}






Re: Problem with Access-MemoField that contains Data > 255 characters by Grzegorz

Grzegorz
Mon Nov 15 09:13:31 CST 2004

U¿ytkownik "Oliver Krüger" <oliverk@datadesign.de> napisa³ w wiadomo¶ci
news:OFT3jLyyEHA.2876@TK2MSFTNGP12.phx.gbl...
>
(...)

> Hi Grzegorz
> Thanks for your fast reply!!!
>
> For my solution I use a DataAdapter :
>
> internal void SQLQueryRead(string p_sSql, ref DataTable p_Data)
> {
> string sPath = @"database\ckdata.mdb";
> string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Persist
> Security Info=False;Data Source=" + sPath;
>
> OleDbConnection oleDbConnection = new
> OleDbConnection(sConnectionString);
> OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(p_sSql,
> oleDbConnection);
> oleDbDataAdapter.Fill(p_Data);
> oleDbConnection.Close();
>
> //Only for testing
> //The MemoCommon-Field contains a text string with 500 characters
> //The Console.WriteLine() output is 255 :-(
> try{
> string myString = p_Data.Rows[0]["MemoCommon"].ToString();
> Console.WriteLine(myString.Length.ToString());
> }
> catch{}
> }
>

I have made another snippet (using DataTable):

using System;
using System.Data;
using System.Data.OleDb;

namespace TestAccessMemo
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Test t = new Test();
t.FillDataTable();

System.Console.ReadLine();
}
}

class Test
{
OleDbConnection con = new OleDbConnection();
public Test()
{
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data Source=E:\NoteDb.mdb;Persist Security Info=False";
}

public void FillDataTable()
{
OleDbDataAdapter da = new OleDbDataAdapter("Select Notes From tblData",
con);
DataTable dt = new DataTable();
da.Fill(dt);

foreach(DataRow dr in dt.Rows)
{
string note = dr[0].ToString();
System.Console.WriteLine("Note in datatable:" +
"\n{0},\n{1} chars", note, note.Length);
}
}
}
}

And it works ok. Maybe you have an error in definition of your datatable
p_Data?
Regards,
Grzegorz


Re: Problem with Access-MemoField that contains Data > 255 characters by Oliver

Oliver
Mon Nov 15 09:36:23 CST 2004


"Grzegorz Danowski" <gdn@usuntopoczta.onet.pl> wrote in message
news:cnah31$57j$1@inews.gazeta.pl...
> U¿ytkownik "Oliver Krüger" <oliverk@datadesign.de> napisa³ w wiadomo¶ci
> news:OFT3jLyyEHA.2876@TK2MSFTNGP12.phx.gbl...
>>
> (...)
>
>> Hi Grzegorz
>> Thanks for your fast reply!!!
>>
>> For my solution I use a DataAdapter :
>>
>> internal void SQLQueryRead(string p_sSql, ref DataTable p_Data)
>> {
>> string sPath = @"database\ckdata.mdb";
>> string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Persist
>> Security Info=False;Data Source=" + sPath;
>>
>> OleDbConnection oleDbConnection = new
>> OleDbConnection(sConnectionString);
>> OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(p_sSql,
>> oleDbConnection);
>> oleDbDataAdapter.Fill(p_Data);
>> oleDbConnection.Close();
>>
>> //Only for testing
>> //The MemoCommon-Field contains a text string with 500 characters
>> //The Console.WriteLine() output is 255 :-(
>> try{
>> string myString = p_Data.Rows[0]["MemoCommon"].ToString();
>> Console.WriteLine(myString.Length.ToString());
>> }
>> catch{}
>> }
>>
>
> I have made another snippet (using DataTable):
>
> using System;
> using System.Data;
> using System.Data.OleDb;
>
> namespace TestAccessMemo
> {
> class Class1
> {
> [STAThread]
> static void Main(string[] args)
> {
> Test t = new Test();
> t.FillDataTable();
>
> System.Console.ReadLine();
> }
> }
>
> class Test
> {
> OleDbConnection con = new OleDbConnection();
> public Test()
> {
> con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
> @"Data Source=E:\NoteDb.mdb;Persist Security Info=False";
> }
>
> public void FillDataTable()
> {
> OleDbDataAdapter da = new OleDbDataAdapter("Select Notes From tblData",
> con);
> DataTable dt = new DataTable();
> da.Fill(dt);
>
> foreach(DataRow dr in dt.Rows)
> {
> string note = dr[0].ToString();
> System.Console.WriteLine("Note in datatable:" +
> "\n{0},\n{1} chars", note, note.Length);
> }
> }
> }
> }
>
> And it works ok. Maybe you have an error in definition of your datatable
> p_Data?
> Regards,
> Grzegorz

Hi Grzegorz!

I have found the defect :-)
In the SQL-Statement I use a UNION for the Memo fields!

Best regards!

Oliver