I’m using Sybase.AdoNet2.AseClient to access Sybase ASE data from a Console C# Application. Not always, but from time to time I get System.NullReferenceException With following code.
It works well with only one application started, but fails with this exception if I start 10 processes at the same time in my machine.
public void Dummy()
{
List<string> valueList = new List<string>();
AseParameter[] arParms = new AseParameter[1];
arParms[0] = new AseParameter("@date", AseDbType.Date);
arParms[0].Value = Convert.ToDateTime("1/08/2010");
AseCommand spCommand = new AseCommand();
spCommand.CommandType = CommandType.StoredProcedure;
spCommand.Connection = connection;
spCommand.CommandText = "MyStoredProcedure";
spCommand.Parameters.AddRange(arParms);
AseDataReader reader = spCommand.ExecuteReader();
while (reader.Read())
{
if (reader["MyColumn"] != DBNull.Value)
valueList.Add(reader["MyColumn"].ToString());
}
}
It happens in the line of “while (reader.Read())”, and has following call stack.
System.NullReferenceException: Object reference not set to an instance of an object.
at Sybase.Data.AseClient1.AseDataReader.Read()
at Sybase.Data.AseClient.AseDataReader.Read()
at Dummy()
Will be very appreciated if anybody can help me out.