Table of Contents

Method RunSql

Namespace
YndigoBlue.Velocity.Engine
Assembly
YndigoBlue.Velocity.dll

RunSql(string)

Executes a raw SQL command against the database.

public void RunSql(string sql)

Parameters

sql string

The SQL statement to execute.

Examples

using (var m = new Manager(conn))
{
    // Execute a database-specific command
    m.RunSql("ANALYZE TABLE users");

    // Or execute a custom stored procedure
    m.RunSql("CALL update_statistics()");
}

Remarks

Use this method only when the operation you need cannot be expressed through any other Velocity method.

Warning

RunSql should be used as a last resort. Raw SQL is executed directly against the target database and bypasses Velocity's cross-database abstraction layer. SQL written for one database system will frequently not work on another, so use of this method risks breaking portability across database systems.

Exceptions

DbException

Thrown when a database error occurs.