Import from SQL table(not axapta) to Axapta tables

Get our Free Newletter

Don't you have the time to be online here at DUG every day? So how do you follow what is going on in the Dynamics industry and community?
If you subscribe to the DUG Newsletter then you can relax! We will make sure that you don't miss the big news!

Check out our
Newsletter Subscription Center
page a complete list of our different newsletters.

This post has 6 Replies | 2 Followers

Not Ranked
Posts 8
80 Points
Joined: Feb 28, 2004
Last Online:
Mar 13, 2007 8:55
Location: New York USA
art2003 Posted: Jan 9, 2006 4:47
How helpful was this post/question? Please rate here:
Hi, guys

I need to import data from SQL table which is populated by other process(outside of axapta application) to Axapta tables.
How to do that?
This table could be on the same server where Axapta db is.

thank you
Top 150 Contributor
Male
Posts 168
1,210 Points
Joined: Nov 5, 2004
Last Online:
Mar 22, 2010 7:39
Location: Melbourne, Australia
Khue Trinh replied on Jan 9, 2006 20:16
How helpful was this comment/solution? Please rate here:
Hi,
Personally, I would like to write a job in Axapta.
-Read data from external database using class ODBC. Here is the sample code:
static void ODBCRead(Args _args)
{
LoginProperty LP = new LoginProperty();
OdbcConnection myConnection;
Statement myStatement;
ResultSet myResult;
;

LP.setDSN("Northwind");

myConnection = new OdbcConnection(LP);

myStatement = myConnection.createStatement();
myResult = myStatement.executeQuery("SELECT * FROM Customers");

while (myResult.next())
{
info(strfmt("%1 %2", myResult.getString(1), myResult.getString(2)));
}
}

-insert data to Axapta and include all the logic that may have.

Hope this can help.
Regards, Khue Trinh
Not Ranked
Posts 8
80 Points
Joined: Feb 28, 2004
Last Online:
Mar 13, 2007 8:55
Location: New York USA
art2003 replied on Jan 12, 2006 6:43
How helpful was this comment/solution? Please rate here:
thank you for your response, i have used what you suggested, it worked.

But using the same objects is it possible to call stored procedure, instead of ExecuteQuery or ExecuteUpdate?

I need also create another process, which after table in Axapta is populated from ImportTable(not Axapta table), update some fields in ImportTable.
I would rather do it in stored proc, using "Update ImportTable select ....from Axapta table", it would be much more effective, that looping again thru records.
Do u know the way to call stored proc?
thank you.
Top 150 Contributor
Male
Posts 168
1,210 Points
Joined: Nov 5, 2004
Last Online:
Mar 22, 2010 7:39
Location: Melbourne, Australia
Khue Trinh replied on Jan 12, 2006 18:33
How helpful was this comment/solution? Please rate here:
Hi
I tried using Store Proc in Axapta sometimes ago, but I did not get too far as Axapta doesn't support developer to call SProc in standard.

You may want to look at the ADO connection class (try "find" method on AOT to get the class name) and find out how to call a SP.

Regards,
Regards, Khue Trinh
Top 25 Contributor
Male
Posts 749
8,199 Points
Joined: Jan 21, 2003
Last Online:
Mar 19, 2010 11:43
Location: Herts, England
DynamicsAXMVP
Moderator
Harish Mohanbabu replied on Jan 12, 2006 23:56
How helpful was this comment/solution? Please rate here:
Hi,

You can execute a stored proc from Axapta like -
Connection Con = new Connection();
Statement Stmt = Con.createStatement();
ResultSet R = Stmt.executeQuery('<STORED_PROCEDURE_NAME>');

while (R.next())
{
print R.getString(1);
}

I have used stored proc from Axapta in the past to import data from another SQL database into Axapta. Overall it works ok. But there are quite a few drawbacks using this route.

Regards,

Harish Mohanbabu

Harish Mohanbabu
Long way to go before I sleep ..

View Harish Mohanbabu's profile on LinkedIn

Not Ranked
Posts 2
20 Points
Joined: Dec 18, 2007
Last Online:
Dec 28, 2007 9:57
sudvaep replied on Dec 18, 2007 11:47
How helpful was this comment/solution? Please rate here:

Guys can any body Reply me for, how to insert a record in Sql Server from Ax4.0 with out using Axapta Table.

Thanks in advance!

sudvaep

Top 25 Contributor
Male
Posts 749
8,199 Points
Joined: Jan 21, 2003
Last Online:
Mar 19, 2010 11:43
Location: Herts, England
DynamicsAXMVP
Moderator
Harish Mohanbabu replied on Jan 3, 2008 15:07
How helpful was this comment/solution? Please rate here:

Hi Sudvaep,

I guess you want to write to external SQL tables from Ax 4.0.  I would write a stored procedure in SQL and call that from Ax.  For example

----------------------------------------------------------------

....................................

sqlStat = strfmt("%1 %2", <Name of stored procedure>, curext());

stmt.execute(sqlStat);

----------------------------------------------------------------

In the above string, I am formatting the stored procedure name along with an input parameter.  I like using stored procedure as I find it an elegant option.  But there is no reason why a SQL statement can't be used instead.

Hope this helps,

Harish Mohanbabu
Long way to go before I sleep ..

View Harish Mohanbabu's profile on LinkedIn

Page 1 of 1 (7 items) | Get this RSS feed | Bookmark and Share