U¿ytkownik "Oliver Krüger said:
(...)
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