Skip to content

Classes and functions

子悦解说 edited this page Aug 13, 2025 · 1 revision

Global functions

SQLiteConnection ConnectSQLite(const char path)

Returns an SQLiteConnection with the specified database. Remember to Close() after finishing using it.

SQLiteCommand CreateSQLiteCommand(const char sql, SQLiteConnection conn)

Preparing a SQL statement with the specified database, no matter whether it requires preparing.

  • sql is the SQL statement.
  • conn is the database connection.
  • Returns an SQLiteCommand.

SQLiteConnection

SQLiteConnection object represents a connection with an SQLite database.

bool IsOpen()

Return whether the connection is good or not.

void Close()

Close the connection. Remember to invoke this.

SQLiteCommand

SQLiteCommand object represents a command that is ready for being executed. All commands are assumed as a prepared statement.

void BindParameter(int index, int value)
void BindParameter(int index, float value)
void BindParameter(int index, const char value)

Binding a parameter by its index. Note that the index starts from 1.

void BindParameterNull(int index)

Binding a parameter with NULL by its index. Note that the index starts from 1.

void BindParameter(const char param, int value)
void BindParameter(const char param, float value)
void BindParameter(const char param, const char value)

Binding a parameter by its name.

void BindParameterNull(const char param)

Binding a parameter with NULL by its name.

int ExecuteNonQuery()

Executes the command against the connection and returns the number of rows affected. You can use ExecuteNonQuery() to perform any type of database operation, however any result returned will not be available. The statement will be reset after being invoked, meaning that parameters are cleared.

SQLiteDataReader ExecuteReader()

Returns an SQLiteDataReader that can be used for reading query results.

void Finalize()

Finalize the object. Remember to invoke this.

SQLiteDataReader

Provides a means of reading a forward-only stream of query results.

bool Read()

Advances the reader to the next record. You need to invoke this first to get results after you get the reader.

  • Returns whether there are more rows to get.

const char GetName(int index)

Find the name of a column by its index.

int GetInt(int index)
float GetFloat(int index)
const char GetText(int index)

Get the data by the column index. Note that the index starts from 1.

int GetInt(const char column)
float GetFloat(const char column)
const char GetText(const char column)

Get the data by the column name.

bool IsDBNull(int index)

Check whether the data is NULL by the column index. Note that the index starts from 1.

bool IsDBNull(const char column)

Check whether the data is NULL by the column name.

void Close()

Close the reader and reset the command. Remember to invoke this.