Tuesday, November 8, 2011

Dynamics AX SSRS The request failed with HTTP status 401

Question : 
I am receiving a 401 error when connecting to AX Reports hosted on SSRS 2008 R2.


Answer :
The solution that worked for me was to open rsreportserver.config file placed in the reporting services instalaltion directory, finding authentication group and commenting WindowsNegotiate tag as shown below.

 
   
   
 
  true

Monday, October 24, 2011

Dynamics AX Log On Failed on Reporting Services

Query:

I am getting a logon failure when running reporting services for dynamics.

Answer:

Make sure the business connector credentials are correct.

Sunday, October 23, 2011

Seconds to actual time in C#

I always used to have issues when debugging time related issues in AX. Time is saved in seconds so many time when you want to know the actual time associated with it in hh : mm :  ss, you will either have to do it in mind or use a calculator. In order to simplify debugging I have created a small C# based console application that takes seconds as input and returns the time in actual format.

The code is below and you can compile it in visual studio to make it work.

Enjoy!

Download the application from here.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Decimal2Hours
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine(Program.ConvertSecondsToHoursMinutes(Console.ReadLine()));
            }
        }


        public static string ConvertDecimalToHours(string paramHours)
        {
            int realPart;
            int decimalPart;
            decimal hours;
            string hoursStr;
            string minStr;
            int decimalLocation;
            string finalMinutes;
            decimal _hours = decimal.Parse(paramHours);
            ;
            try
            {
                hours = _hours;
                hoursStr = hours.ToString();
                decimalLocation = hoursStr.IndexOf(".");
                hoursStr = hoursStr.Substring(0, decimalLocation);
                hoursStr = hoursStr.Trim(new char[] { '.' });
                minStr = hours.ToString();
                minStr = minStr.Substring(decimalLocation);
                minStr = minStr.Trim(new char[] { '.' });
                realPart = Convert.ToInt32(hoursStr);
                decimalPart = Convert.ToInt32(Math.Floor((decimal)Convert.ToDecimal("0." + minStr) * 60));
                finalMinutes = (realPart.ToString().Length == 1 ? "0" + realPart.ToString() : realPart.ToString())
                                + ":" +
                                (decimalPart.ToString().Length == 1 ? "0" + decimalPart.ToString() : decimalPart.ToString());
                return finalMinutes;
            }
            catch
            {
                return paramHours;
            }
        }


        public static string ConvertSecondsToHoursMinutes(string paramSeconds)
        {
            string finalTime;
            int seconds = Convert.ToInt32(paramSeconds);
            int result;
            int hours = Math.DivRem(seconds, 60 * 60, out result);
            seconds = result;
            int minutes = Math.DivRem(seconds, 60, out result);
            seconds = result;


            finalTime = hours.ToString() + " : " + minutes.ToString() + " : " + seconds.ToString();


            return finalTime;
        }
    }
}

Monday, October 17, 2011

Dynamics AX Excel Sheet Import, In Correct Time Values

Query
Whenever I import an excel sheet containing a timing point, it is converted to 1 second less than the actual value. 


Answer
This is a known issue and you can look at http://support.microsoft.com/kb/969186 for the resolution and workaround. 

Wednesday, October 12, 2011

SharePoint Database Configuration Failed

Query :


I changed the DNS IP today and was unable to connect to SharePoint database. The error that i am getting is "Failed to connect to the configuration database"


Answer :
There can be many factors to cause this issue. You can read about this issue at "http://support.microsoft.com/kb/823287/en-us". 


One more issue can be the change of the IP of your DNS Server. In order to resolve most of the issues you can create a new database using the following command,


  "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\PSCONFIG.EXE" -cmd configdb -create -database

Tuesday, August 23, 2011

Excel Value to String

Query: How can i create a generic method for returning string values from excel.

Answer:

// convert into str from excel cell value
str COMVariant2Str(COMVariant _cv,
                    int _decimals = 0,
                        int _characters = 0,
                        int _separator1 = 0,
                        int _separator2 = 0)
{
    switch (_cv.variantType())
    {
        case (COMVariantType::VT_BSTR):
            return _cv.bStr();

        case (COMVariantType::VT_R4):
            return num2str(_cv.float(),_characters,_decimals,_separator1,_separator2);

        case (COMVariantType::VT_R8):
            return num2str(_cv.double(),_characters,_decimals,_separator1,_separator2);

        case (COMVariantType::VT_DECIMAL):
            return num2str(_cv.decimal(),_characters,_decimals,_separator1,_separator2);

        case (COMVariantType::VT_DATE):
            return date2str(_cv.date(),123,2,1,2,1,4);

        case (COMVariantType::VT_EMPTY):
            return "";

        default:
            throw error(strfmt("@SYS26908", _cv.variantType()));
    }
    return "";
}

Wednesday, August 17, 2011

Corrupted applicationHost.config

Query:
The IIS file applicationHost.config got corrupted today, is there any way i can regenerate?

Answer:
You can restore from the backup placed at C:\inetpub\history

Monday, August 15, 2011

ssrs unable to load client print control on windows 2003

Query:
I am getting an issue when trying to print the SSRS reports. It keeps saying "unable to load client print control".


Answer:

Uninstall KB KB956390