Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to display varchar

Author  Topic 

szhizzo
Starting Member

3 Posts

Posted - 2010-09-10 : 05:36:46

Hi,

I have a small problem:

I want to display a column from a table:

wscript.echo "DiskReq: " & program.DiskReq

Definition of the column: DiskReq(varchar(20), null)

I get always an error:

test.vbs(96, 1) Microsoft VBScript runtime error:
Object doesn't support this property or method: 'program.DiskReq'

Thx

Andreas

Sachin.Nand

2937 Posts

Posted - 2010-09-10 : 05:37:59
It seems more like a VBScript related problem than SQL.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

szhizzo
Starting Member

3 Posts

Posted - 2010-09-10 : 05:40:53
Hi,

normally I agree... But I tried it also with Visual C#

Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-09-10 : 05:51:04
Post the code.Hope some one here understands VBScript.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

szhizzo
Starting Member

3 Posts

Posted - 2010-09-10 : 06:38:44
Hi,

Dim connection
computer = "192.168.100.1"
userName = "Administrator"
userPassword = "xxxxxxxxxxxxxxxxx"

Set connection = Connect(computer,userName,userPassword)

If Err.Number<>0 Then
Wscript.Echo "Call to connect failed"
End If

Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set swbemServices= swbemLocator.ConnectServer("192.168.100.1", "root\sms")
Set providerLoc = swbemServices.InstancesOf("SMS_ProviderLocation")

For Each Location In providerLoc
If location.ProviderForLocalSite = True Then
Set swbemServices = swbemLocator.ConnectServer(Location.Machine, "root\sms\site_" + Location.SiteCode)
Exit For
End If
Next

Call SNIPPETMETHODNAME(connection)

Sub SNIPPETMETHODNAME(connection)

' Build query to get all of the packages.
packageQuery = "SELECT * FROM SMS_Package"

' Run query.
Set allPackages = connection.ExecQuery(packageQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)

' The query returns a collection of package objects that needs to be enumerated.
For Each package In allPackages

' Output package name and get the PackageID value to use in program query.
wscript.echo ""
wscript.echo "Package: " & package.Name
packageID = package.PackageID

' Build query to get the programs for the package.
packageQuery = "SELECT * FROM SMS_Program WHERE PackageID='" & packageID & "'"

' Run query.
Set programsForPackage = connection.ExecQuery(packageQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)

query9 = "select diskreq as reqdisk from PkgPrograms"


Set test = connection.ExecQuery(query9)

' The query returns a collection of program objects that needs to be enumerated.

For Each program In programsForPackage

wscript.echo " Program: " & program.ProgramName
wscript.echo " Maximum Runtime Value: " & program.Duration
wscript.echo "ProgramID: " & program.ProgramID
wscript.echo "Command: " & program.Command
wscript.echo "Comment: " & program.Comment
wscript.echo "Description: " & program.Description
wscript.echo "Requirements: " & program.Requirements
wscript.echo "Hierarchy: " & program.Hierarchy
wscript.echo "WorkingDir: " & program.WorkingDir
wscript.echo "DependentProgram: " & program.DependentProgram
wscript.echo "DriveLetter: " & program.DriveLetter
wscript.echo "SourceSite: " & program.SourceSite
wscript.echo "DiskReq: " & reqdisk
wscript.echo "RemovalKey: " & program.RemovalKey
wscript.echo "ProgramFlags: " & program.ProgramFlags
wscript.echo "DeviceFlags: " & program.DeviceFlags
wscript.echo "Duration: " & program.Duration
wscript.echo "MSIProduktID: " & program.MSIProduktID
wscript.echo "MSIFilePath: " & program.MSIFilePath
wscript.echo "UpdateMask: " & program.UpdateMask
wscript.echo "Action: " & program.Action
wscript.echo "Icon: " & program.Icon
wscript.echo "ExtData: " & program.ExtData
wscript.echo "ISVData: " & program.ISVData
wscript.echo "SourceLocaleID: " & program.SourceLocaleID
wscript.echo "rowversion: " & program.rowversion

Next

Next

End Sub

Function Connect(server, userName, userPassword)


Dim net
Dim localConnection
Dim swbemLocator
Dim swbemServices
Dim providerLoc
Dim location

Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")

swbemLocator.Security_.AuthenticationLevel = 6 'Packet Privacy

' If the server is local, don't supply credentials.
Set net = CreateObject("WScript.NetWork")
If UCase(net.ComputerName) = UCase(server) Then
localConnection = true
userName = ""
userPassword = ""
server = "."
End If

' Connect to the server.
Set swbemServices= swbemLocator.ConnectServer _
(server, "root\sms",userName,userPassword)
If Err.Number<>0 Then
Wscript.Echo "Couldn't connect: " + Err.Description
Connect = null
Exit Function
End If


' Determine where the provider is and connect.
Set providerLoc = swbemServices.InstancesOf("SMS_ProviderLocation")

For Each location In providerLoc
If location.ProviderForLocalSite = True Then
Set swbemServices = swbemLocator.ConnectServer _
(location.Machine, "root\sms\site_" + _
location.SiteCode,userName,userPassword)
If Err.Number<>0 Then
Wscript.Echo "Couldn't connect:" + Err.Description
Connect = Null
Exit Function
End If
Set Connect = swbemServices
Exit Function
End If
Next
Set Connect = null ' Failed to connect.
End Function
Go to Top of Page
   

- Advertisement -