Dynamicweb Namespace > Database Class > ExecuteScalar Method : ExecuteScalar(String) Method |
namespace Dynamicweb.Examples.CSharp { class DatabaseExecute { public void ExecuteSample() { //ExecuteScalar var pageCount = Input.FormatInteger(Database.ExecuteScalar("SELECT COUNT(PageID) FROM Page")); //ExecuteScalar on alternate database var userCount = Input.FormatInteger(Database.ExecuteScalar("SELECT COUNT(AccessUserID) FROM AccessUser")); //ExecuteNonQuery var numberOfPagesDeleted = Database.ExecuteNonQuery("DELETE FROM Page WHERE PageID < 101"); //ExecuteNonQuery on alternate database var numberOfUsersDeleted = Database.ExecuteNonQuery("DELETE FROM AccessUser WHERE AccessUserID < 101", "Access.mdb"); } } }
Public Class DatabaseExecute Public Sub ExecuteSample() 'ExecuteScalar Dim pageCount As Integer = Input.FormatInteger(Database.ExecuteScalar("SELECT COUNT(PageID) FROM Page")) 'ExecuteScalar on alternate database Dim userCount As Integer = Input.FormatInteger(Database.ExecuteScalar("SELECT COUNT(AccessUserID) FROM AccessUser")) 'ExecuteNonQuery Dim numberOfPagesDeleted As Integer = Database.ExecuteNonQuery("DELETE FROM Page WHERE PageID < 101") 'ExecuteNonQuery on alternate database Dim numberOfUsersDeleted As Integer = Database.ExecuteNonQuery("DELETE FROM AccessUser WHERE AccessUserID < 101", "Access.mdb") End Sub End Class
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