Showing posts with label Ax. Show all posts
Showing posts with label Ax. Show all posts

Tuesday, 12 January 2016

How to Restore the Database with code

Hi Guys,

This is the following command to restore the Database with given .bak file.

DECLARE @fileList TABLE (backupFile NVARCHAR(255))
DECLARE @lastFullBackup NVARCHAR(500)
DECLARE @cadpath NVARCHAR(500)

INSERT INTO @fileList(backupFile)
EXEC xp_cmdshell 'dir C:\AX-Databases\*.bak'


select @lastFullBackup = substring(MAX(backupFile),CHARINDEX('H', MAX(backupFile)),8000) from @fileList
WHERE backupFile LIKE '%.bak'
AND backupFile LIKE '%'+'test' + '%'

set @cadpath = 'C:\AX-Databases\' + @lastFullBackup
RESTORE DATABASE test_Live FROM DISK = @cadpath



Vivek Chirumamilla

Monday, 15 December 2014

C# code to use in Ax for fetching records

Hi Friends,

Here is the C# sharp code to login and retreive records in Ax

using System;
using System.Data;
using System.Security.Permissions;
using Microsoft.Dynamics.Framework.Reports;
using System.Data.SqlClient;

public partial class test
{

[DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
public static System.Data.DataTable DataMethod1()
{

System.Data.DataTable customers2 = new DataTable();
string queryString = "SELECT * FROM dbo.CustTable";

SqlConnection connection = new SqlConnection();
connection.ConnectionString =
"Data Source=@server;" +
"Initial Catalog=@DB;" +
"Integrated Security=SSPI;";

SqlCommand cmd = new SqlCommand(queryString, connection);

connection.Open();
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());

return dt;


}

}




Vivek Chirumamilla

Tuesday, 28 October 2014

Address System in Ax 2012 R3

Hi Friends,

Ax 2012 has a complex Address when compared to the previous versions of Ax.

In this address is not directly linked to the Customer or Vendor directly.

Customer or Vendor has Party which is linked to the DirParty.

DirParty Contains the Primary postal address reference to Logistics Location RecId which is reflected in LogisticsPostalAddress.

In short Dirparty contains the value of Location for searching address in LogisticsPostalAddress.

Vivek Chirumamilla