But did you write this code - convert(varchar(10),res.ResultTime,120) as Sample Data - in AX 2012??
It seems for me that this code is for SQL and not Axapta
But did you write this code - convert(varchar(10),res.ResultTime,120) as Sample Data - in AX 2012??
It seems for me that this code is for SQL and not Axapta
Anyway, I will try it!
Thanks a lot Piotr
Exactly like this:
objConn.Open();
cmdSelect = objConn.CreateCommand();
inventBatchId = subStr(caller.inventBatchId(), strFind(caller.inventBatchId(),’-’,1,100)+1,100);
cmdSelect.set_CommandText("select CAST(res.WorkstationId as varchar)+’’+CAST(res.SampleIndex as varchar)+’’"
+"+CAST(res.Intakenumerator as varchar)+’’+CAST(res.syntheticnumerator as varchar) as recID " //+’’+CAST(dc.cid as varchar) as recID "
reader = cmdSelect.ExecuteReader();
Hope this code helps! [:D]
static void TestODBC()
{
LoginProperty loginProperty;
OdbcConnection odbcConnection;
Statement statement;
ResultSet resultSet;
str sql, criteria;
SqlStatementExecutePermission perm;
;
//Set information on the ODBC
loginProperty = new LoginProperty();
loginProperty.setDSN(“dsn”);
loginProperty.setDatabase(“databaseName”);
//Create connection to external DB
odbcConnection = new OdbcConnection(loginProperty);
if (odbcConnection)
{
sql = “SELECT * FROM MYTABLE WHERE FIELD =” +
criteria + " ORDER BY FIELD1,FIELD2 ASC";
//assert permission for sql string
perm = new SqlStatementExecutePermission(sql);
perm.assert();
//Prepare statement
statement = odbcConnection.createStatement();
resultSet = statement.executeQuery(sql);
//Running statement
while (resultSet.next())
{
//It is not possible to get field 3 and then 1.Always get fields in numerical order: 1,2,3,4,5,6
print resultSet.getString(1);
print resultSet.getString(3);
}
//Shutting down the connection
resultSet.close();
statement.close();
}
else
error(“Failed to log on to the database”);
}