Table of Contents

Class CPDbBaseClass

Namespace
Contensive.BaseClasses
Assembly
CPBase.dll

CP.Db - This object references the database directly

public abstract class CPDbBaseClass : IDisposable
Inheritance
CPDbBaseClass
Implements
Inherited Members

Properties

SQLTimeout

get or set the timeout in seconds for all Db methods in the current process

public abstract int SQLTimeout { get; set; }

Property Value

int

Methods

Add(string, int)

Add a record to a table in the default datasource and return its Id

public abstract int Add(string tableName, int createdByUserId)

Parameters

tableName string
createdByUserId int

Returns

int

CreateFieldPathFilename(string, string, int, FieldTypeIdEnum)

creates a pathFilename for a field that stores text content, like css, js, etc.

public abstract string CreateFieldPathFilename(string tableName, string fieldName, int recordId, CPContentBaseClass.FieldTypeIdEnum fieldTypeId)

Parameters

tableName string
fieldName string
recordId int
fieldTypeId CPContentBaseClass.FieldTypeIdEnum

Returns

string

CreateFieldPathFilename(string, string, int, fileTypeIdEnum)

Deprecated

[Obsolete("Deprecated. Use CreateUploadFieldPathFilename with no fieldType or FileType", false)]
public abstract string CreateFieldPathFilename(string tableName, string fieldName, int recordId, CPContentBaseClass.fileTypeIdEnum fieldType)

Parameters

tableName string
fieldName string
recordId int
fieldType CPContentBaseClass.fileTypeIdEnum

Returns

string

CreateUploadFieldPath(string, string, int)

creates a path for a field that holds the path and filename of an uploaded file (Only type=file and type=image)

public abstract string CreateUploadFieldPath(string tableName, string fieldName, int recordId)

Parameters

tableName string
fieldName string
recordId int

Returns

string

CreateUploadFieldPathFilename(string, string, int, string)

creates the pathFilename for a field that holds the path and filename of an uploaded file (Only type=file and type=image)

public abstract string CreateUploadFieldPathFilename(string tableName, string fieldName, int recordId, string filename)

Parameters

tableName string
fieldName string
recordId int
filename string

Returns

string

CreateUploadFieldPathFilename(string, string, int, string, FieldTypeIdEnum)

Deprecated

[Obsolete("Deprecated. Use CreateUploadFieldPathFilename with no fieldType or FileType", false)]
public abstract string CreateUploadFieldPathFilename(string tableName, string fieldName, int recordId, string filename, CPContentBaseClass.FieldTypeIdEnum fieldTypeId)

Parameters

tableName string
fieldName string
recordId int
filename string
fieldTypeId CPContentBaseClass.FieldTypeIdEnum

Returns

string

CreateUploadFieldPathFilename(string, string, int, string, fileTypeIdEnum)

Deprecated

[Obsolete("Deprecated. Use CreateUploadFieldPathFilename with no fieldType or FileType", false)]
public abstract string CreateUploadFieldPathFilename(string tableName, string fieldName, int recordId, string filename, CPContentBaseClass.fileTypeIdEnum fileType)

Parameters

tableName string
fieldName string
recordId int
filename string
fileType CPContentBaseClass.fileTypeIdEnum

Returns

string

DbGetConnectionString(string)

Deprecated

[Obsolete("Use GetConnectionString( dataSourceName )")]
public abstract string DbGetConnectionString(string DataSourcename)

Parameters

DataSourcename string

Returns

string

DbGetDataSourceType(string)

Deprecated

[Obsolete("Use GetDataSourceType( dataSourceName )")]
public abstract int DbGetDataSourceType(string DataSourcename)

Parameters

DataSourcename string

Returns

int

DbGetTableID(string)

Deprecated

[Obsolete("Use GetTableId instead.", false)]
public abstract int DbGetTableID(string TableName)

Parameters

TableName string

Returns

int

DbIsTable(string, string)

Deprecated

[Obsolete("Use isTable instead", false)]
public abstract bool DbIsTable(string DataSourcename, string TableName)

Parameters

DataSourcename string
TableName string

Returns

bool

DbIsTableField(string, string, string)

Deprecated

[Obsolete("Use isTableField instead", false)]
public abstract bool DbIsTableField(string DataSourcename, string TableName, string FieldName)

Parameters

DataSourcename string
TableName string
FieldName string

Returns

bool

Delete(string, int)

Delete the record specified by tablename and recordId

public abstract void Delete(string tableName, int recordId)

Parameters

tableName string
recordId int

Delete(string, string)

Delete the record specified by tablename and guid

public abstract void Delete(string tableName, string guid)

Parameters

tableName string
guid string

Delete(string, string, int)

Deprecated

[Obsolete("Deprecated. Use methods without datasource reference. Instead create non-default datasource with CP.DbNew(datasourcename).", false)]
public abstract void Delete(string dataSourcename, string tableName, int recordId)

Parameters

dataSourcename string
tableName string
recordId int

DeleteRows(string, string)

Delete the record specified by tablename and guid

public abstract void DeleteRows(string tableName, string sqlCriteria)

Parameters

tableName string
sqlCriteria string

The sql delete statement where criteria. Cannot be blank.

Dispose()

Support disposable for non-default datasources

public abstract void Dispose()

EncodeSQLBoolean(bool)

Encode a boolean value to be used in an sql Query for this application. Boolean fields are stored as integers in Contensive. Example 'select id from ccmembers where active='+EncodeSqlBoolean(true)

public abstract string EncodeSQLBoolean(bool sourceBoolean)

Parameters

sourceBoolean bool

Returns

string

EncodeSQLDate(DateTime)

Encode a date value to be used in an sql Query for this application. Example 'select id from ccmembers where dateadded>'+EncodeSqlDate( myBirthday )

public abstract string EncodeSQLDate(DateTime sourceDate)

Parameters

sourceDate DateTime

Returns

string

EncodeSQLNumber(double)

Encode a numeric value (integer or double) to be used in an sql Query for this application. Example 'select id from orders where totalAmount>'+EncodeSqlNumber( 1000.00 )

public abstract string EncodeSQLNumber(double sourceNumber)

Parameters

sourceNumber double

Returns

string

EncodeSQLNumber(int)

Encode a numeric value (integer or double) to be used in an sql Query for this application. Example 'select id where id>'+EncodeSqlNumber( 1000 )

public abstract string EncodeSQLNumber(int sourceNumber)

Parameters

sourceNumber int

Returns

string

EncodeSQLText(string)

Encode a text string value to be used in an sql Query for this application. Example 'select id where name='+EncodeSqlText( 'bob' )

public abstract string EncodeSQLText(string sourceText)

Parameters

sourceText string

Returns

string

EncodeSQLTextLike(string)

Encode a text string value to be used in an sql Query for this application. Example 'select id where name like '+EncodeSqlText( 'bob' )

public abstract string EncodeSQLTextLike(string sourceText)

Parameters

sourceText string

Returns

string

ExecuteNonQuery(string)

Execute an sql command on a specific datasource. No data is returned.

public abstract void ExecuteNonQuery(string sql)

Parameters

sql string

ExecuteNonQuery(string, ref int)

Execute an sql command on a specific datasource. No data is returned.

public abstract void ExecuteNonQuery(string sql, ref int recordsAffected)

Parameters

sql string
recordsAffected int

ExecuteNonQuery(string, string)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract void ExecuteNonQuery(string sql, string dataSourceName)

Parameters

sql string
dataSourceName string

ExecuteNonQuery(string, string, ref int)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract void ExecuteNonQuery(string sql, string dataSourceName, ref int recordsAffected)

Parameters

sql string
dataSourceName string
recordsAffected int

ExecuteNonQueryAsync(string)

Execute an sql command on a specific datasource, dotnet async task pattern.

public abstract Task<int> ExecuteNonQueryAsync(string sql)

Parameters

sql string

Returns

Task<int>

ExecuteNonQueryAsync(string, string)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract void ExecuteNonQueryAsync(string sql, string dataSourceName)

Parameters

sql string
dataSourceName string

ExecuteQuery(string)

Execute an sql query and return a datatable. Start at record 0, max records returned is 10M.

public abstract DataTable ExecuteQuery(string sql)

Parameters

sql string

Returns

DataTable

ExecuteQuery(string, int)

Execute an sql query and return a datatable. Max records returned is 10M.

public abstract DataTable ExecuteQuery(string sql, int startRecord)

Parameters

sql string
startRecord int

0 based start record

Returns

DataTable

ExecuteQuery(string, int, int)

Execute a query and return a datatable.

public abstract DataTable ExecuteQuery(string sql, int startRecord, int maxRecords)

Parameters

sql string
startRecord int

0 based start record

maxRecords int

Returns

DataTable

ExecuteQuery(string, string)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract DataTable ExecuteQuery(string sql, string dataSourceName)

Parameters

sql string
dataSourceName string

Returns

DataTable

ExecuteQuery(string, string, int)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract DataTable ExecuteQuery(string sql, string dataSourceName, int startRecord)

Parameters

sql string
dataSourceName string
startRecord int

Returns

DataTable

ExecuteQuery(string, string, int, int)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract DataTable ExecuteQuery(string sql, string dataSourceName, int startRecord, int maxRecords)

Parameters

sql string
dataSourceName string
startRecord int
maxRecords int

Returns

DataTable

ExecuteRemoteQuery(string)

Execute a sql query stored with getRemoteQueryKey.

public abstract DataTable ExecuteRemoteQuery(string remoteQueryKey)

Parameters

remoteQueryKey string

Returns

DataTable

ExecuteSQL(string)

Deprecated

[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL)

Parameters

SQL string

Returns

object

ExecuteSQL(string, string)

Deprecated

[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL, string DataSourcename)

Parameters

SQL string
DataSourcename string

Returns

object

ExecuteSQL(string, string, string)

Deprecated

[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL, string DataSourcename, string Retries)

Parameters

SQL string
DataSourcename string
Retries string

Returns

object

ExecuteSQL(string, string, string, string)

Deprecated

[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL, string DataSourcename, string Retries, string PageSize)

Parameters

SQL string
DataSourcename string
Retries string
PageSize string

Returns

object

ExecuteSQL(string, string, string, string, string)

Deprecated

[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL, string DataSourcename, string Retries, string PageSize, string PageNumber)

Parameters

SQL string
DataSourcename string
Retries string
PageSize string
PageNumber string

Returns

object

ExecuteScalar(string)

Execute an sql query and return an integer. query should return a single value.

public abstract int ExecuteScalar(string sql)

Parameters

sql string

Returns

int

GetConnectionString()

get the connection string for the default device

public abstract string GetConnectionString()

Returns

string

GetConnectionString(string)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract string GetConnectionString(string dataSourcename)

Parameters

dataSourcename string

Returns

string

GetDataSourceType(string)

Deprecated

[Obsolete("Only Sql Server currently supported", false)]
public abstract int GetDataSourceType(string DataSourcename)

Parameters

DataSourcename string

Returns

int

GetRemoteQueryKey(string)

To give a remote method the ability to run an arbitrary query, store it as a remote query and executeRemoteQuery()

public abstract string GetRemoteQueryKey(string sql)

Parameters

sql string

Returns

string

GetRemoteQueryKey(string, int)

To give a remote method the ability to run an arbitrary query, store it as a remote query and executeRemoteQuery()

public abstract string GetRemoteQueryKey(string sql, int pageSize)

Parameters

sql string
pageSize int

Returns

string

GetRemoteQueryKey(string, string)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract string GetRemoteQueryKey(string sql, string DataSourceName)

Parameters

sql string
DataSourceName string

Returns

string

GetRemoteQueryKey(string, string, int)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract string GetRemoteQueryKey(string sql, string DataSourceName, int pageSize)

Parameters

sql string
DataSourceName string
pageSize int

Returns

string

GetTableID(string)

Deprecated

[Obsolete("Deprecated. Use CP.Content.GetTableId().", false)]
public abstract int GetTableID(string tableName)

Parameters

tableName string

Returns

int

Insert(string, NameValueCollection, int)

Add a record to a table and return the record in a datatable

public abstract DataTable Insert(string tableName, NameValueCollection sqlList, int createdByUserId)

Parameters

tableName string

The table to be inserted.

sqlList NameValueCollection

NameValue pairs to be inserted. Name is the field name. Value is saved to the field, formatted for an sql statement according to the correct type. ex sqlList.Add("name", cp.db.EncodeSqlText("Bob Smith"))

createdByUserId int

The user id to be set in the created-by and modified-by fields

Returns

DataTable

Insert(string, int)

Add a record to a table and return the record in a datatable

public abstract DataTable Insert(string tableName, int createdByUserId)

Parameters

tableName string
createdByUserId int

Returns

DataTable

IsTable(string)

Return true if this is a valid database table in the current application

public abstract bool IsTable(string tableName)

Parameters

tableName string

Returns

bool

IsTable(string, string)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract bool IsTable(string dataSourcename, string tableName)

Parameters

dataSourcename string
tableName string

Returns

bool

IsTableField(string, string)

Return true if this is a valid database field in a valid table in the current application

public abstract bool IsTableField(string tableName, string fieldName)

Parameters

tableName string
fieldName string

Returns

bool

IsTableField(string, string, string)

Deprecated

[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract bool IsTableField(string dataSourcename, string tableName, string fieldName)

Parameters

dataSourcename string
tableName string
fieldName string

Returns

bool

Update(string, string, NameValueCollection)

update records in a table. Criteria is an sql compatible where-clause, the sqlList is a list of fields and values to update

public abstract void Update(string tableName, string criteria, NameValueCollection sqlList)

Parameters

tableName string

The table to be updated.

criteria string

Sql compatible where clause to select the record(s) that will be updated.

sqlList NameValueCollection

NameValue pairs. Name is the field name. Value is saved to the field, formatted for an sql statement according to the correct type. ex sqlList.Add("name", cp.db.EncodeSqlText("Bob Smith"))

Update(string, string, NameValueCollection, bool)

update records in a table. Criteria is an sql compatible where-clause, the sqlList is a list of fields and values to update. If Async is true, the query is queued for later

public abstract void Update(string tableName, string criteria, NameValueCollection sqlList, bool Async)

Parameters

tableName string
criteria string
sqlList NameValueCollection
Async bool