Not connecting to SQL Database during OSD
I am working with SCCM and I want to display some item from Database during OSD. But its not making the connection with SQL database : following is my VB script,and i am connecting with a SQL express database. Do i need to add any driver. This step is running after apply operting system step in the task sequence. MsgBox("Started") Set db = CreateObject("ADODB.Connection") cnstring = "Provider=SQLOLEDB.1;Password=myPassword;Persist Security Info=True;User ID=sa;Initial Catalog=Serial;Data Source=Myserver\SQLExpress" db.open cnstring Dim rs Set rs = CreateObject("ADODB.recordset") Set rs = db.Execute ("Select * from machine where sn = 12345) strValue = rs("Dept") MsgBox(strValue) Script is executing fine in a running OS, but not executing during OSD. Any help would be appreciated. Thanks Chandan
May 24th, 2011 6:57am

You must add ADO/MDAC support to the boot image if you want to query the DB from WinPEMichael Petersen http://blog.coretech.dk/mip/
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2011 7:15am

to access the DB in WinPE, create a boot image with ADO support - heres how (see screenshot 4) My step by step SCCM Guides I'm on Twitter > ncbrady
May 24th, 2011 7:46am

or if you do not want to create a new bootimage open a prompt, navigate to where your Boot.wim file is located, and write md mount Dism /Mount-Wim /WimFile:boot.wim /Index:1 /MountDir:mount Dism /image:mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-mdac.cab" Dism /Unmount-Wim /MountDir:mount /Commit rd mount Update DPMichael Petersen http://blog.coretech.dk/mip/
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2011 8:01am

I have tried the both way but it did not worked. MsgBox("Started") The above is working from the code and i have got the message box. But the next message box MsgBox(strValue) is not showing. Thanks Chandan
May 24th, 2011 9:38am

I wrote this to validate MAC addresses in the MDT database, you may be able to adapt it to your database: Function GetMAC(LocalMAC) on error resume next ' Connect to the MDT database and compare the MAC with values in the Database and set the set ValidateMAC variable to true if we it. ' Set cn = CreateObject("ADODB.Connection") Set objRecordset = CreateObject("ADODB.Recordset") cn.Open "Driver={SQL Server}; Server=yourserver; Database=MDT2010; USER ID=MDTQuery;password=password" objRecordset.CursorLocation = adUseClient strQuery = "SELECT * FROM dbo.ComputerIdentity WHERE MacAddress ='" & LocalMAC & "'" 'wscript.echo LocalMAC objRecordset.Source = strQuery objRecordset.Open strQuery, cn, adOpenStatic,adLockOptimistic ' ' If we have a recordset then set ValidateMAC variable in the OSD environment. ' if Not objRecordset.EOF then ' set ValidateMAC variable in the OSD environment. env("ValidateMAC") = "True" wscript.quit else env("ValidateMAC") = "False" oLogging.CreateEntry "MAC Address not validated for " + LocalMAC , LogTypeWarning 'wscript.echo "False" end if End Function
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2011 6:39am

THanks to everyone for your help. I have added the port number in the connection string and it started working. cnstring = "Provider=SQLOLEDB.1;Password=myPassword;Persist Security Info=True;User ID=sa;Initial Catalog=Serial;Data Source=Myserver\SQLExpress,1433" Thanks Chandan
May 25th, 2011 7:23am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics