A few days ago I had the good fortune of helping a customer troubleshoot an issue calling SQL Stored Procedures from MDT 2012 generated WinPE 4.0 (ADK) boot image.
Note 1:
WinPE 4.0 (ADK) boot images should only be used in a Lab, not for production, its still in beta. Please file any issues on Connect.
Note 2:
This issue will be fixed in MDT 2012 Update 1
Symptoms
Normal SQL SELECT calls worked great, but calling SQL Stored Procedures failed. It only failed when using the WinPE 4.0 (ADK) boot image, not when using WinPE 3.0 (WAIK) boot images. During the Gather action the below errors were seen in the log file.
About to issue SQL statement: EXECUTE IdentifyComputer '00:15:5D:0A:74:C6'
ERROR – Opening Record Set (Error Number = -2147467259) (Error Description: Unspecified error).
ADO error: Unspecified error (Error #-2147467259; Source: Microsoft OLE DB Provider for SQL Server; SQL State: ; NativeError: 0)
Unable to execute database query.
Problem Solving
Since the Stored Procedure worked when booting from WinPE 3.0, I knew that server side config and permissions was ok. That led me to believe that WinPE 4.0 was missing something that WinPE 3.0 had.
So I started Process Monitor in WinPE, and shortly I saw that cscript.exe was trying to finding a few files but could not find them. They were present in the WinPE 3.0 boot image, but not in WinPE 4.0. Then I reviewed the logs from when MDT 2012 generated boot images, and I found the following:
/Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\winpe-mdac.cab"
/Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\ar-sa\winpe-mdac_ar-sa.cab
MDT 2012 was simply injecting the wrong language part of the mdac optional component. MDT was adding in the English component but the Arabic (Saudi Arabia) language part of it. Again this will be fixed in MDT 2012 Update 1.


Solution:
Copy the following files from a Windows 8 installation to Program Files\Common Files\System\Ole DB\en-US in the boot image.
msdasqlr.dll.mui
oledb32r.dll.mui
sqloledb.rll.mui
sqlxmlx.rll.mui
This files can be added by mounting the image and added, by using the add extra directory feature in the Deployment Workbench, or by having the UpdateExit.vbs script inject them via DISM or file copying.
/ Johan