Adapter GetSQLdate Method MVC+ (Model-Facade-View-Controller) Framework for ASP.NET
Gets database date value (must be overridden by derived class.)

Namespace: NovaDimension.Data
Assembly: NovaDimension.Data (in NovaDimension.Data.dll) Version: 4.0.204.0 (4.0.0204.0)
Syntax

public abstract string GetSQLdate(
	DateTime pValue
)

Return Value

Type: String
Database date value

Implements

IAdaptable GetSQLdate(DateTime)
Exceptions

Examples

This sample shows how to override the GetSQLdate(DateTime) abstract method.
See Also: AdapterException, LogHelper T 
using system;
using System.Text;
using System.Data.SqlClient;
using NovaDimension.Component;
using NovaDimension.Data;

public class SQLServerAdapter : Adapter
{
    public override String GetSQLdate(DateTime pValue)
    {
        try
        {
            LogHelper<SQLServerAdapter>.DebugBegin(System.Reflection.MethodBase.GetCurrentMethod().Name);

            StringBuilder value = new StringBuilder("convert(DATETIME, '");
            value.Append(String.Format("{0:yyyy/MM/dd HH:mm:ss}", pValue)).Append("' , 101)");
            return value.ToString();
        }
        catch (FormatException ex)
        {
            throw new ExceptionEx<AdapterException>(EnumHelper.Value(AdapterException.ERROR_GETSQLDATE_FORMAT), ex, true);
        }
        catch (Exception ex)
        {
            throw new ExceptionEx<AdapterException>(EnumHelper.Value(AdapterException.ERROR_GETSQLDATE), ex, true);
        }
        finally
        {
            LogHelper<SQLServerAdapter>.DebugEnd(System.Reflection.MethodBase.GetCurrentMethod().Name);
        }
    }
}
See Also