Knight Data Access Layer
ExecuteScalarSproc(String) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > IDataHelper Interface > ExecuteScalarSproc Method : ExecuteScalarSproc(String) Method
The stored procedure to execute
Execute the passed stored procedure and return the first column of the first row
Syntax
Overloads Function ExecuteScalarSproc( _
   ByVal storedProcedure As String _
) As Object
Dim instance As IDataHelper
Dim storedProcedure As String
Dim value As Object
 
value = instance.ExecuteScalarSproc(storedProcedure)
object ExecuteScalarSproc( 
   string storedProcedure
)
Object* ExecuteScalarSproc( 
   string* storedProcedure
) 
Object^ ExecuteScalarSproc( 
   String^ storedProcedure
) 

Parameters

storedProcedure
The stored procedure to execute

Return Value

The value returned from the stored procedure
Example
//Get the current thread static safe instance of the helper
SqlServerProvider provider = new SqlServerProvider();
 
//Specify User Name and License Key from the receipt, leave blank for trial mode
//db.UserName = "John Smith 1234";
//db.LicenseKey = "asdfl219==";
 
//Log to the console
db.EnableLogging();
 
//Open the database connection
db.OpenConnection();
 
//Parameters
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("ExpirationType", "Credit Card");
 
string storedProcedure = "CalculateAverageTransactionSale";
 
decimal results = Convert.ToDecimal(db.ExecuteScalarSproc(storedProcedure));
 
db.CloseConnection();
'Get the current thread static safe instance of the helper
Dim provider As New SqlServerProvider()
 
'Specify User Name and License Key from the receipt, leave blank for trial mode
'db.UserName = "John Smith 1234"
'db.LicenseKey = "asdfl219=="
 
'Log to the console
db.EnableLogging()
 
'Open the database connection
db.OpenConnection()
 
'Parameters
Dim parameters As New Dictionary(Of String, Object)()
parameters.Add("ExpirationType", "Credit Card")
 
Dim storedProcedure As String = "CalculateAverageTransactionSale"
 
Dim results As Decimal = Convert.ToDecimal(db.ExecuteScalarSproc(storedProcedure))
 
db.CloseConnection()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IDataHelper Interface
IDataHelper Members
Overload List