Connection string for LINQ to SQL

In my article about connecting to external databases with the help of LINQ to SQL, I already mentioned how to parametrize which database to use, because you’ll likely use different databases for development, test and live environments. I wrote: In real implementations, I usually store DB server and DB name in AX database, create a …

Continue reading ‘Connection string for LINQ to SQL’ »

Connection to external database

You sometimes need to connect from Dynamics AX to another database and read or write data there. The usual approach uses OdbcConnection class, as described on MSDN in How to: Connect to an External Database from X++ Code [AX 2012]. Although it definitely is a possible solution (I used it already in AX 3.0), it …

Continue reading ‘Connection to external database’ »

Custom date and time format

I was extending a customization of Dynamics AX when I ran into the following piece of code. It formats the current date and time to something like 20150525_0042. str dateValue, dateFormat;   dateValue = date2str( systemDateGet(), 321, DateDay::Digits2, DateSeparator::None, DateMonth::Digits2, DateSeparator::None, DateYear::Digits4, DateFlags::FormatAll);   dateFormat = strFmt( "%1%2%3", dateValue, ‘_’, subStr( strRem(time2Str(timeNow(), TimeSeparator::Space, TimeFormat::Auto), ‘ …

Continue reading ‘Custom date and time format’ »

XML DocType in X++

Let’s say that we want to use X++ to create an XML file with the following DocType definition: <!DOCTYPE MyType SYSTEM "http://www.validome.org/check/test.dtd"> AX has Xml* classes (e.g. XmlDocument) for such purpose, but let’s build it with .NET classes first (you’ll see why in a moment). This is X++ code calling .NET classes through .NET Interop: …

Continue reading ‘XML DocType in X++’ »

Instrumentation and tracing

Regardless of how hard we try to write flawless software, sooner or later something goes wrong and we must identify where exactly the problem lies (to be able to fix it). One option is using the debugger, but it’s not always possible – we can’t reproduce the problem, for example. Another way is inserting some …

Continue reading ‘Instrumentation and tracing’ »