[英]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.