ExecuteScalar Method (sqlFormat, args)

Microsoft Deployment Tools

Deployment Tools Foundation ExecuteScalar Method (sqlFormat, args)
Deployment Tools Foundation NamespacesMicrosoft.Deployment.WindowsInstallerDatabaseExecuteScalar(String, array<Object>[]()[])
Executes the specified SQL SELECT query and returns a single result.
Declaration Syntax
C# Visual Basic Visual C++
public Object ExecuteScalar(
	string sqlFormat,
	params Object[] args
)
Public Function ExecuteScalar ( _
	sqlFormat As String, _
	ParamArray args As Object() _
) As Object
public:
Object^ ExecuteScalar(
	String^ sqlFormat, 
	... array<Object^>^ args
)
Parameters
sqlFormat (String)
SQL query string, which may contain format items
args (array< Object >[]()[])
Zero or more objects to format
Return Value
First field of the first result
Remarks

The sqlFormat parameter is formatted using Format(String, array<Object>[]()[]).

Win32 MSI APIs: MsiDatabaseOpenView, MsiViewExecute, MsiViewFetch

Exceptions
Exception Condition
BadQuerySyntaxException the SQL syntax is invalid
InstallerException the View could not be executed or the query returned 0 results
InvalidHandleException the Database handle is invalid

Assembly: Microsoft.Deployment.WindowsInstaller (Module: Microsoft.Deployment.WindowsInstaller) Version: 3.0.0.0 (3.5.1623.0)