本文整理汇总了C++中Database::Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::Disconnect方法的具体用法?C++ Database::Disconnect怎么用?C++ Database::Disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::Disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleInput
void DatabaseDemo::HandleInput(const String& input)
{
// Echo input string to stdout
Print(input);
row_ = 0;
if (input == "quit" || input == "exit")
engine_->Exit();
else if (input.StartsWith("set") || input.StartsWith("get"))
{
// We expect a key/value pair for 'set' command
Vector<String> tokens = input.Substring(3).Split(' ');
String setting = tokens.Size() ? tokens[0] : "";
if (input.StartsWith("set") && tokens.Size() > 1)
{
if (setting == "maxrows")
maxRows_ = Max(ToUInt(tokens[1]), 1U);
else if (setting == "connstr")
{
String newConnectionString(input.Substring(input.Find(" ", input.Find("connstr")) + 1));
Database* database = GetSubsystem<Database>();
DbConnection* newConnection = database->Connect(newConnectionString);
if (newConnection)
{
database->Disconnect(connection_);
connection_ = newConnection;
}
}
}
if (tokens.Size())
{
if (setting == "maxrows")
Print(ToString("maximum rows is set to %d", maxRows_));
else if (setting == "connstr")
Print(ToString("connection string is set to %s", connection_->GetConnectionString().CString()));
else
Print(ToString("Unrecognized setting: %s", setting.CString()));
}
else
Print("Missing setting paramater. Recognized settings are: maxrows, connstr");
}
else
{
// In this sample demo we use the dbCursor event to loop through each row as it is being fetched
// Regardless of this event is being used or not, all the fetched rows will be made available in the DbResult object,
// unless the dbCursor event handler has instructed to filter out the fetched row from the final result
DbResult result = connection_->Execute(input, true);
// Number of affected rows is only meaningful for DML statements like insert/update/delete
if (result.GetNumAffectedRows() != -1)
Print(ToString("Number of affected rows: %d", result.GetNumAffectedRows()));
}
Print(" ");
}