Table of Contents

Class SqlHelper

Namespace
Tripous.Data
Assembly
Tripous.Data.dll

A collection of static methods for manipulating Sql statements.

public class SqlHelper
Inheritance
SqlHelper
Inherited Members
Extension Methods

Fields

StatementDefaultSpaces

The spaces to be used when generating Sql statements

public const int StatementDefaultSpaces = 30

Field Value

int

Methods

DateTimeToStr(DateTime, bool)

Formats Value. Quotes the result if Quoted is true.

public static string DateTimeToStr(DateTime Value, bool Quoted)

Parameters

Value DateTime
Quoted bool

Returns

string

DateToStr(DateTime, bool)

Formats Value. Quotes the result if Quoted is true.

public static string DateToStr(DateTime Value, bool Quoted)

Parameters

Value DateTime
Quoted bool

Returns

string

ExtractTableName(string)

If the specified CreateTableSqlText is a CREATE TABLE TABLE_NAME (...) sql statement then this method returns the TABLE_NAME, else returns string.Empty

public static string ExtractTableName(string CreateTableSqlText)

Parameters

CreateTableSqlText string

Returns

string

FieldAlias(string, string)

Constructs a field at table string. By default is TableName__FieldName.

public static string FieldAlias(string TableName, string FieldName)

Parameters

TableName string
FieldName string

Returns

string

FieldPath(string, string)

Returns a string of the form TableName.FieldName

public static string FieldPath(string TableName, string FieldName)

Parameters

TableName string
FieldName string

Returns

string

FloatSQL(double)

Converts the double Value to a float string, valid for S, i.e. ensures that the decimal seperator is the point.

public static string FloatSQL(double Value)

Parameters

Value double

Returns

string

FloatSql(string)

Converts the string Value to a float string, valid for S, i.e. ensures that the decimal

public static string FloatSql(string Value)

Parameters

Value string

Returns

string

Format(object)

Returns the value of the Value as a string for constructing Sql statements.

In case of a string or DateTime it surrounds the result with single quotes.

public static string Format(object Value)

Parameters

Value object

Returns

string

FormatFieldNameAlias(string, string, int)

Returns a string such as

FieldName as Alias

public static string FormatFieldNameAlias(string FieldName, string Alias, int Spaces)

Parameters

FieldName string
Alias string
Spaces int

Returns

string

FormatFieldNameAlias(string, string, string, int)

Returns a string such as

TableNameOrAlias.FieldName as Alias

public static string FormatFieldNameAlias(string TableNameOrAlias, string FieldName, string Alias, int Spaces)

Parameters

TableNameOrAlias string
FieldName string
Alias string
Spaces int

Returns

string

FormatId(object)

Returns the value of the Id as a string for constructing Sql statements.

Id could be either a guid string or a 32-bit integer.

public static string FormatId(object Id)

Parameters

Id object

Returns

string

FormatTableNameAlias(string, string)

Returns a string such as

TableName Alias

public static string FormatTableNameAlias(string TableName, string Alias)

Parameters

TableName string
Alias string

Returns

string

GetMainTableName(string)

WARNING: Not reliable

public static string GetMainTableName(string SelectSqlText)

Parameters

SelectSqlText string

Returns

string

IsMasked(string)

Returns true if Value contains any of the mask characters (%, ?, *)

public static bool IsMasked(string Value)

Parameters

Value string

Returns

bool

NormalizeMask(string)

Normalizes Value for use in a LIKE clause. It returns a string as 
LIKE 'VALUE%'
<p>Value may or may not contain mask characters (%, ?, *)</p>
public static string NormalizeMask(string Value)

Parameters

Value string

Returns

string

NormalizeMask2(string)

Normalizes Value for use in a LIKE clause. It returns a string as 
LIKE 'VALUE%'
<p>Value may or may not contain mask characters (%, ?, *)</p>
<p>WARNING: This version adds a % in front of Value, if not there</p>
public static string NormalizeMask2(string Value)

Parameters

Value string

Returns

string

NormalizeMaskForce(string)

Normalizes Value for use in a LIKE clause. It returns a string as 
LIKE 'VALUE%'
<p>Value may or may not contain mask characters (%, ?, *)</p>
public static string NormalizeMaskForce(string Value)

Parameters

Value string

Returns

string

TimeToStr(DateTime, bool)

Formats Value. Quotes the result if Quoted is true.

public static string TimeToStr(DateTime Value, bool Quoted)

Parameters

Value DateTime
Quoted bool

Returns

string

TransformToFieldList(List<string>)

Transforms a string list into a field list by adding a , and a line break in every string item, except the last one.

public static string TransformToFieldList(List<string> StringList)

Parameters

StringList List<string>

Returns

string