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{}
}