Knight Data Access Layer
RecordExists(String) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > DataHelper Class > RecordExists Method : RecordExists(String) Method
The SQL to execute
Returns true if the record exists
Syntax
Public Overloads Overridable Function RecordExists( _
   ByVal sql As String _
) As Boolean
Dim instance As DataHelper
Dim sql As String
Dim value As Boolean
 
value = instance.RecordExists(sql)
public virtual bool RecordExists( 
   string sql
)
public: virtual bool RecordExists( 
   string* sql
) 
public:
virtual bool RecordExists( 
   String^ sql
) 

Parameters

sql
The SQL to execute

Return Value

True if one ore more records exist
Example
//Get the current thread static safe instance of the helper
IDataHelper db = DataHelper.SessionFactory();
 
//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();
 
//Create a new Person to save to the database
Person currentPerson = new Person();
currentPerson.FirstName = "John";
currentPerson.LastName = "Smith";
 
//Save it to the database 
db.Save(currentPerson);
 
string sql = "select * from persons";
 
bool exists = db.RecordExists(sql);
 
db.CloseConnection();
'Get the current thread static safe instance of the helper
Dim db As IDataHelper = DataHelper.SessionFactory()
 
'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()
 
'Create a new Person to save to the database
Dim currentPerson As New Person()
currentPerson.FirstName = "John"
currentPerson.LastName = "Smith"
 
'Save it to the database 
db.Save(currentPerson)
 
Dim sql As String = "select * from persons"
 
Dim exists As Boolean = db.RecordExists(sql)
 
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

DataHelper Class
DataHelper Members
Overload List