<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="https://www.schweda.net/style_feed.css" ?>
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:atom="http://www.w3.org/2005/Atom"	
	xmlns:dc="http://purl.org/dc/elements/1.1/" > 
<channel>
    <title>schweda.net - Blog</title>
    <link>https://www.schweda.net/</link>
    <description>schweda.net - Blog - Blog-Beitraege</description>
    <language>de-at</language>
    <copyright>Copyright 2006-2026</copyright>
    <generator>schweda.net</generator>
    <managingEditor>heinz.schweda@schweda.net (Heinz Schweda)</managingEditor>
    <webMaster>heinz.schweda@schweda.net (Heinz Schweda)</webMaster>
    <category>Blog</category>
	<atom:link href="https://www.schweda.net/blog_rss.php?bid=220" rel="self" type="application/rss+xml" />
<item>
<title><![CDATA[Dynamics AX: Zugriff auf externe Datenbank via ADO]]></title>
<description><![CDATA[
<p>Um aus AX4 auf eine externe Datenbank zugreifen zu k&ouml;nnen, kann man sich der Klasse CCADOConnection bedienen, nachstehend findet Ihr zwei Beispiele wie diese verwendet werden kann.
</p>

<p>&nbsp;
</p>

<p>Aufruf &uuml;ber DSN
</p>

<div class="div_blog_axcode">static void TestADO_via_DSN(Args _args)<br />
{<br />
&nbsp;&nbsp;&nbsp; CCADOConnection&nbsp;&nbsp;&nbsp;&nbsp; adoConnection;<br />
&nbsp;&nbsp;&nbsp; CCADORecordSet&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adoRecordSet = new CCADORecordSet();<br />
&nbsp;&nbsp;&nbsp; str&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLstring = &quot;SELECT * FROM table&quot;;<br />
&nbsp;&nbsp;&nbsp; ;<br />
&nbsp;&nbsp;&nbsp; adoConnection = new CCADOConnection();<br />
&nbsp;&nbsp;&nbsp; adoConnection.connectionString(&quot;Dsn=NameOfDSN&quot;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Am lokalen PC installierte System-DSN<br />
&nbsp;&nbsp;&nbsp; adoConnection.open();<br />
<br />
&nbsp;&nbsp;&nbsp; adoRecordSet.open(SQLstring, adoConnection);<br />
<br />
&nbsp;&nbsp;&nbsp; while (!adoRecordSet.EOF())<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info(adoRecordSet.fields().itemIdx(1).value());&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Erstes Feld<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info(adoRecordSEt.fields().itemName(&quot;fieldname&quot;).value());&nbsp; // Bestimmtes Feld<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adoRecordSet.moveNext();<br />
&nbsp;&nbsp;&nbsp; }<br />
}
</div>

<p>Aufruf ohne DSN
</p>

<div class="div_blog_axcode">static void TestADO(Args _args)<br />
{<br />
&nbsp;&nbsp;&nbsp; CCADOConnection&nbsp;&nbsp;&nbsp;&nbsp; adoConnection;<br />
&nbsp;&nbsp;&nbsp; CCADORecordSet&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adoRecordSet = new CCADORecordSet();<br />
&nbsp;&nbsp;&nbsp; str&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLstring = &quot;SELECT * FROM table&quot;;<br />
&nbsp;&nbsp;&nbsp; ;<br />
&nbsp;&nbsp;&nbsp; adoConnection = new CCADOConnection();<br />
&nbsp;&nbsp;&nbsp; adoConnection.connectionString(&quot;Driver={SQL Server};Server=servername;Database=databasename;UID=user; PWD=pass&quot;);<br />
&nbsp;&nbsp;&nbsp; adoConnection.open();<br />
<br />
&nbsp;&nbsp;&nbsp; adoRecordSet.open(SQLstring, adoConnection);<br />
<br />
&nbsp;&nbsp;&nbsp; while (!adoRecordSet.EOF())<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info(adoRecordSet.fields().itemIdx(1).value());&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Erstes Feld<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info(adoRecordSEt.fields().itemName(&quot;fieldname&quot;).value());&nbsp; // Bestimmtes Feld<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adoRecordSet.moveNext();<br />
&nbsp;&nbsp;&nbsp; }<br />
}
</div>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Fri, 25 Apr 2008 15:21:00 +0200</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=220</link>
<comments>https://www.schweda.net/blog_ax.php?bid=220</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=220</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=220</wfw:commentRss>
</item>
<item>
<title>Kommentar von Daniel</title>
<description><![CDATA[Hallo Heinz, anbei im Link ein weiteres Beispiel. Liebe Grüße, Daniel]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Thu, 10 Oct 2013 14:27:00 +0200</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=220</link>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=220</guid>
<author>Daniel</author>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Heinz Schweda</dc:creator>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=220</wfw:commentRss>
</item>
<item>
<title>Kommentar von Daniel</title>
<description><![CDATA[http://jaysaltonaxdev.blogspot.co.at/2009/09/ccadoconnection-tutorial.html]]></description>
<category></category>
<pubDate>Thu, 10 Oct 2013 14:28:00 +0200</pubDate>
<link>https://www.schweda.net/blog.php?bid=220</link>
<guid isPermaLink="true">https://www.schweda.net/blog.php?bid=220</guid>
<author>Daniel</author>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Heinz Schweda</dc:creator>
<wfw:commentRss>https://www.schweda.net/blog.php?bid=220</wfw:commentRss>
</item>
<item>
<title>Kommentar von Max</title>
<description><![CDATA[Hallo Heinz, benutze CCADO schon eine Zeit lang. Und es läuft gut um Daten abzuholen. Jetzt ist aber ein DateTime Feld hinzugekommen und ich ich bekomme leider nur das value Datum und nicht die Zeit. Gibt es hierfür eine Lösung? Danke mfg Max]]></description>
<category></category>
<pubDate>Tue, 24 Jun 2014 13:49:00 +0200</pubDate>
<link>https://www.schweda.net/blog.php?bid=220</link>
<guid isPermaLink="true">https://www.schweda.net/blog.php?bid=220</guid>
<author>Max</author>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Heinz Schweda</dc:creator>
<wfw:commentRss>https://www.schweda.net/blog.php?bid=220</wfw:commentRss>
</item>
<item>
<title>Kommentar von Heinz Schweda</title>
<description><![CDATA[Hallo Max,
eine Lösung habe ich jetzt grade nicht parat, aber wie wärs wenn du bereits beim SELECT-Statement die Konvertierungsfunktionen der jeweiligen Datenbank-Engine nutzt?
Also beispielsweise bei einem SQL Server würde ich ein DateTime-Feld wie folgt (entweder mit CAST oder CONVERT) in einen String konvertieren und im AX mit String-Funktionen mir die notwendigen Informationen extrahieren.

Nicht unbedingt die eleganteste Variante, aber eine Möglichkeit.

SELECT cast([dateTimeFieldName] as nvarchar(20)) as DateTimeAsStr
,convert(varChar(23), [dateTimeFieldName] ,  121) as DateTimeAsStr2
FROM tableName

Grüsse Heinz]]></description>
<category></category>
<pubDate>Thu, 26 Jun 2014 09:33:00 +0200</pubDate>
<link>https://www.schweda.net/blog.php?bid=220</link>
<guid isPermaLink="true">https://www.schweda.net/blog.php?bid=220</guid>
<author>Heinz Schweda</author>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Heinz Schweda</dc:creator>
<wfw:commentRss>https://www.schweda.net/blog.php?bid=220</wfw:commentRss>
</item>
</channel>
</rss>	
