I use Dynamics AX 2012 with business connector in C# for retrieving data by odbc methods.
I'm using SQL Server 2008 R2 (version 10.50.2500 - not AX database).
The code looks like this:
using MIL = Miceoaodr.Dynamics.AX.ManagedInterop;
...
namespae mynamespace
{
public class myclass
{
public static MIL.Session axSession = null;
...
public void test()
{
MIL.Container c;
OdbcDataReader r;
OdbcConnection conn;
OdbcCommand cmd;
object o;
conn = new OdbcConnection("my connection string");
conn.open();
cmd = new OdbcCommand("select * from mytable", conn);
r = cmd.ExecuteReader();
while (r.Read())
{
c.clear();
for (int i = 0; i < reader.FieldCount; i++)
{
o = reader.getValue(i);
c.Add(o); // **** fails sometimes
}
}
c = new MIL.Container();
c.add(0); // **** here is the problem. program halts without any **** warning!
}
}
}
The line with asterisks fails sometimes (c.add(0)... ).
It seems that it fails only of table-colums that their type in db that are: int, or for type that are bigint with the value = 0.
What shall I do in order code will not fails like described?
Thanks :)