When using OleDBDataReader to select the memo field from the Access database, it returns part of the string. How can I get the whole line?

This is my code:

OleDbConnection connection = new OleDbConnection(
   "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\Offline.accdb;Persist Security Info=False");
connection.Open();
OleDbCommand command = connection.CreateCommand();
command.CommandText = "SELECT DISTINCT B.* FROM BlankFormSubmissions B, Actions A WHERE A.FormName = 'FindingNemo' AND B.ProcessName = A.ProcessName AND B.ActionName = A.ActionName AND B.ID = 12 OR B.ID = 13 OR B.ID = 14 ORDER BY B.ID";
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
    string xml = (string)reader["XML"];
    // ... do something with xml
}

The XML column is an Access database column of type memo.

The xml value always contains only the first characters of the XML. I assume these are the first 256 characters. Obviously, I need all the characters in the string.

Does anyone know how to fix this?

Thank:)

+3
source share
2 answers

The problem may lie in the memo field itself:

Memo (, Max, Var, Sum ..). "Group By" 255 . "" "" Group Aggregate 255 "" "" .

SQL?

+5

;)

 OleDbCommand sqlcmdCommand1 = new OleDbCommand("select stmt", sqlconConnection);
        sqlcmdCommand1.CommandType = CommandType.Text;
        try
        {
            sqlconConnection.Open();
            OleDbDataReader sdaResult = sqlcmdCommand1.ExecuteReader();
            myclass a = new myclass();
            while (sdaResult.Read())
            {

               a.i = sdaResult.GetString(2);
               or 
               int i = sdaResult.GetString(2)); 
              // 2 is the index of your column, in general start from 0;'
            }

, , my_memo_value null, : , string int.

Myclass {
Public int i{get;set}
}
0

Source: https://habr.com/ru/post/1795501/


All Articles