Exemple #1
0
EWXWEXPORT(wxDb*,wxDb_GetConnection)(wxDbConnectInf* connectInf,bool fwdCursorsOnly)
{
#ifdef wxUSE_ODBC
  return wxDbGetConnection(connectInf,fwdCursorsOnly);
#else
  return NULL;
#endif
}
Exemple #2
0
//----------------------------------------------------------------------------------------
bool BrowserDB::OnStartDB(int Quiet)
{
    wxStopWatch sw;
    if (!Quiet)
        wxLogMessage(_("\n-I-> BrowserDB::OnStartDB(%s) : Begin "),ODBCSource.c_str());
    if (db_BrowserDB != NULL)
    {
        if (!Quiet)
            wxLogMessage(_("\n-I-> BrowserDB::OnStartDB() : DB is already open."));
        return true;
    }

    DbConnectInf.AllocHenv();

    //---------------------------------------------------------------------------------------
    // Connect to datasource
    //---------------------------------------------------------------------------------------
    DlgUser *p_Dlg;
    p_Dlg = new DlgUser(pDoc->p_MainFrame,pDoc,wxEmptyString);
    p_Dlg->s_DSN      = ODBCSource;
    p_Dlg->s_User     = UserName;
    p_Dlg->s_Password = Password;
    p_Dlg->OnInit();
    p_Dlg->Fit();

    bool OK = false;
    if (p_Dlg->ShowModal() == wxID_OK)
    {
        (pDoc->p_DSN+i_Which)->Usr = p_Dlg->s_User;
        (pDoc->p_DSN+i_Which)->Pas = p_Dlg->s_Password;
        UserName  = p_Dlg->s_User;
        Password  = p_Dlg->s_Password;
        OK = true;
    }
    delete p_Dlg;
    if (OK)
    {
        //--------------------------------------------------------------------------------------
        DbConnectInf.SetDsn(ODBCSource);         // ODBC data source name (created with ODBC Administrator under Win95/NT)
        DbConnectInf.SetUserID(UserName);        // database username - must already exist in the data source
        DbConnectInf.SetPassword(Password);      // password database username
        db_BrowserDB = wxDbGetConnection(&DbConnectInf);
        // wxLogMessage(">>>%s<<<>>>%s<<<",UserName.c_str(),Password.c_str());
        if (db_BrowserDB == NULL)
        {
            DbConnectInf.SetDsn(wxEmptyString);
            DbConnectInf.SetUserID(wxEmptyString);
            DbConnectInf.SetPassword(wxEmptyString);
            if (!Quiet)
            {
                wxLogMessage(_("\n-E-> BrowserDB::OnConnectDataSource() DB CONNECTION ERROR : Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the table prior to making a connection\n(using tools provided by the database manufacturer)"));
                wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End - Time needed : %ld ms"),ODBCSource.c_str(),sw.Time());
            }
            DbConnectInf.FreeHenv();
            return false;
        }
        //--------------------------------------------------------------------------------------
        if (!Quiet)
        {
            Temp1 = db_BrowserDB->GetDatabaseName();
            Temp2 = db_BrowserDB->GetDataSource();
            wxLogMessage(_("-I-> BrowserDB::OnGetDataSourceODBC() - DatabaseName(%s) ; DataSource(%s)"),Temp1.c_str(),Temp2.c_str());
            wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End - Time needed : %ld ms"),ODBCSource.c_str(),sw.Time());
        }
        return true;
    }
    else
    {
        DbConnectInf.FreeHenv();
        return false;
    }
}