简体   繁体   English

使用OleDBDataReader从Access数据库中选择备注字段时,它只返回字符串的一部分。我怎样才能获得整个字符串?

[英]When using OleDBDataReader to select a memo field from an Access database it only returns part of the string. How can I get the whole string?

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 column, "XML", is an Access Database table column, of type memo. 列“XML”是一个类型为memo的Access Database表列。

The value of xml always contains only the first characters of the XML. xml的值始终只包含XML的第一个字符。 I'm guessing it's the first 256 characters. 我猜它是前256个字符。 Obviously, I need all of the characters in the string. 显然,我需要字符串中的所有字符。

Anyone know how to fix this? 有人知道怎么修这个东西吗?

Thanks :) 谢谢 :)

The problem could be the memo field itself; 问题可能是备忘录领域本身;

Memo fields can't be used in Aggregate Arguments ( like Max, Var, Sum etc. ) If used in 'Group By' totals in a query only the first 255 characters are returned. 备注字段不能用于聚合参数(如Max,Var,Sum等)。如果在查询中使用“分组依据”总计,则仅返回前255个字符。 'Having' and 'Where' clauses in Group Aggregate functions also return only the first 255 chars However, using 'First' or 'Last' arguments return the full length of the string. Group Aggregate函数中的'having'和'Where'子句也只返回前255个字符但是,使用'First'或'Last'参数返回字符串的全长。

Is this the entire SQL statement? 这是整个SQL语句吗?

this way;) 这条路;)

 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;'
            }

if this do not work , i mean if you the value of my_memo_value is null then: create a class in which you get and set value of string and int. 如果这不起作用,我的意思是如果你的my_memo_value的值为null,那么:创建一个你得到的类,并设置string和int的值。 and then use it here Like 然后在这里使用它喜欢

Myclass {
Public int i{get;set}
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在C#中使用OleDbDataReader时无法从Access数据库读取字段信息 - can't read field info from access database when using OleDbDataReader in C# C#使用OleDbDataReader从Access数据库获取值 - c# using OleDbDataReader to get value from Access database 使用 OleDbDataReader 从 Access 数据库中获取 ID 列表 - Get list of IDs from Access Database using OleDbDataReader 从字符串中提取GUID。 我该怎么做? - Extract a GUID from a string. How can I do it? 使用SqlReader,当使用reader.GetString(1)-OR- reader [“ Details”]时,它仅检索字符串的4000字节。 我如何得到其余的? - Using SqlReader, when using reader.GetString(1) -OR- reader[“Details”], it only retrieves 4000 bytes of the string. How do I get the rest? 显示来自“ System.Data.OleDb.OleDbDataReader”的“字符串”。 访问数据库到C#表单 - Display a 'string' from 'System.Data.OleDb.OleDbDataReader'. Access Database to C# Form 如何从 SQLite 数据库中以字符串数据类型的形式从 Select 查询中获取数据? - How can I get data from a Select query as a String data type from a SQLite database? 如何获得以下字符串的一部分? - How can I get part of the following string? 如何从字符串中获取所需的部分? - How to I get the desired part from the string? DBF文件的备注字段仅使用VFP OLE DB Provider for .NET返回一些字符 - Memo field from DBF file only returns a few characters using VFP OLE DB Provider for .NET
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM