本文整理汇总了C++中hm::String::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Find方法的具体用法?C++ String::Find怎么用?C++ String::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hm::String
的用法示例。
在下文中一共展示了String::Find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetDefaultDatabase
STDMETHODIMP InterfaceDatabase::SetDefaultDatabase(eDBtype ServerType, BSTR ServerName, long lPort, BSTR DatabaseName, BSTR Username, BSTR Password)
{
try
{
if (!GetIsServerAdmin())
return GetAccessDenied();
HM::String sEmpty;
HM::String sServerName = ServerName;
HM::String sDatabaseName = DatabaseName;
HM::String sUsername = Username;
HM::String sPassword = Password;
if (sDatabaseName.Find(_T(" ")) >= 0)
return COMError::GenerateError("The database name may not contain spaces.");
// Create a settings object for the connection ...
std::shared_ptr<HM::DatabaseSettings> pSettings = std::shared_ptr<HM::DatabaseSettings>(
new HM::DatabaseSettings(sServerName, sEmpty, sUsername, sPassword, sEmpty, sEmpty,(HM::DatabaseSettings::SQLDBType) ServerType, lPort));
// Connect to the database server.
std::shared_ptr<HM::DALConnection> pConn = HM::DALConnectionFactory::CreateConnection(pSettings);
HM::String sErrorMessage;
if (pConn->Connect(sErrorMessage) != HM::DALConnection::Connected)
return COMError::GenerateError(sErrorMessage);
// Disconnect again.
pConn->Disconnect();
ini_file_settings_->SetDatabaseDirectory("");
ini_file_settings_->SetDatabaseType((HM::DatabaseSettings::SQLDBType) ServerType);
ini_file_settings_->SetUsername(sUsername);
ini_file_settings_->SetPassword(sPassword);
ini_file_settings_->SetDatabasePort(lPort);
ini_file_settings_->SetDatabaseServer(sServerName);
ini_file_settings_->SetDatabaseName(sDatabaseName);
ini_file_settings_->SetIsInternalDatabase(ServerType == hDBTypeMSSQLCE);
return S_OK;
}
catch (...)
{
return COMError::GenerateGenericMessage();
}
}
示例2: CreateExternalDatabase
STDMETHODIMP InterfaceDatabase::CreateExternalDatabase(eDBtype ServerType, BSTR ServerName, long lPort, BSTR DatabaseName, BSTR Username, BSTR Password)
{
try
{
if (!config_)
return GetAccessDenied();
if (!GetIsServerAdmin())
return GetAccessDenied();
const HM::String sEmpty;
const HM::String sServerName = ServerName;
const HM::String sDatabaseName = DatabaseName;
const HM::String sUsername = Username;
const HM::String sPassword = Password;
if (sDatabaseName.Find(_T(" ")) >= 0)
return COMError::GenerateError("The database name may not contain spaces.");
// Create a settings object for the connection ...
std::shared_ptr<HM::DatabaseSettings> pSettings = std::shared_ptr<HM::DatabaseSettings>(
new HM::DatabaseSettings(sServerName, sEmpty, sUsername, sPassword, sEmpty, sEmpty,(HM::DatabaseSettings::SQLDBType) ServerType, lPort));
// Connect to the database serve
std::shared_ptr<HM::DALConnection> pConn = HM::DALConnectionFactory::CreateConnection(pSettings);
HM::String sErrorMessage;
if (pConn->Connect(sErrorMessage) != HM::DALConnection::Connected)
return COMError::GenerateError(sErrorMessage);
// Create the database
HM::String sCreateDB = HM::SQLStatement::GetCreateDatabase(pSettings, sDatabaseName);
if (!pConn->Execute(HM::SQLCommand(sCreateDB), sErrorMessage, 0, 0))
return COMError::GenerateError(sErrorMessage);
// Disconnect again.
pConn->Disconnect();
// Create a new settings object where we specify the database name as well.
pSettings = std::shared_ptr<HM::DatabaseSettings>(
new HM::DatabaseSettings(sServerName, sDatabaseName, sUsername, sPassword, sEmpty, sEmpty,(HM::DatabaseSettings::SQLDBType) ServerType, lPort));
// Reconnect to the new database.
pConn = HM::DALConnectionFactory::CreateConnection(pSettings);
if (pConn->Connect(sErrorMessage) != HM::DALConnection::Connected)
return COMError::GenerateError(sErrorMessage);
// Run the scripts
HM::SQLScriptRunner scriptRunner;
if (!scriptRunner.ExecuteScript(pConn, pSettings->GetDefaultScript(), sErrorMessage))
return COMError::GenerateError(sErrorMessage);
ini_file_settings_->SetDatabaseDirectory("");
ini_file_settings_->SetDatabaseType((HM::DatabaseSettings::SQLDBType) ServerType);
ini_file_settings_->SetUsername(sUsername);
ini_file_settings_->SetPassword(sPassword);
ini_file_settings_->SetDatabasePort(lPort);
ini_file_settings_->SetDatabaseServer(sServerName);
ini_file_settings_->SetDatabaseName(sDatabaseName);
ini_file_settings_->SetIsInternalDatabase(false);
return S_OK;
}
catch (...)
{
return COMError::GenerateGenericMessage();
}
}