I'm using C# (Visual Studio 2015) and communicating with MS Access database. My code below works fine, except that the _statusLadder
variable is returning an empty value from a Memo data type field (I run the same query in MS Access and it pulls the correct memo value).
I have also tried:
string _statusLadder = "";
Can someone help me figure out how to retrieve a Memo data type field from MS Access?
See code:
private string retrieveJobByID(int xID)
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "SELECT TOP 1 [ID], [JOB_NUM], [CUSTOMER], [MODELNO], [CREATE_DATE], [MODEL_FAMILY], [VER], [COM_PROTOCOL], [STATUS_LADDER] FROM tbl_job_tables WHERE([ID] = ?)";
command.Parameters.Add("@ID", OleDbType.Integer).Value = xID;
OleDbDataReader reader = command.ExecuteReader();
string _id = "", _jobnum = "", _customer = "", _modelFamily = "", _modelNum = "", _createDate = "", _ver = "", _comProtocol = "";
var _statusLadder = "";
while (reader.Read())
{
_id = reader["ID"].ToString();
_jobnum = reader["JOB_NUM"].ToString();
_customer = reader["CUSTOMER"].ToString();
_modelFamily = reader["MODEL_FAMILY"].ToString();
_modelNum = reader["MODELNO"].ToString();
_createDate = reader["CREATE_DATE"].ToString();
_ver = reader["VER"].ToString();
_comProtocol = reader["COM_PROTOCOL"].ToString();
_statusLadder = reader["STATUS_LADDER"].ToString(); //<-- This returns empty when it should be ~300 characters.
Console.WriteLine("Status is: " + _statusLadder);
}
if (!reader.IsClosed)
{
reader.Close();
}
if (connection.State == ConnectionState.Open) {
connection.Close();
}
string result = _id + "|" + _jobnum + "|" + _customer + "|" + _modelFamily + "|" + _modelNum + "|" + _createDate + "|" + _ver + "|" + _comProtocol + "|" + _statusLadder;
return result;
}
EDIT - Here's some pictures of my MS Access 2010 setup (ACCDB):
(1) - The first shows the SQL query. I entered ID=116 as a parameter
(2) - The second picture shows the result from the query. You can see that "STATUS_LADDER" returns the proper value.
(3) - This is the setup of the table (in Design Mode) for the Field "STATUS_LADDER"