Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. DataBase variables

DataBase variables

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasequestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RuiSantiago
    wrote on last edited by
    #1

    Hi! I'm working on a application that uses MSAccess database, i run SQL commands like : kl.Format("%s%s%s","SELECT Maquina.nicname FROM Maquina WHERE Maquina.maquinaid='", machineid,"'"); pRst->Open((_bstr_t)kl, strConn, adOpenStatic, adLockReadOnly, adCmdText); Therefor, to use this commands i need this two variables : _RecordsetPtr pRst("ADODB.Recordset"); _bstr_t strConn("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=proteres.mdb"); I've been defining them locally in all my functions, but now i was trying to make them global for the all application, or even the same class, but i get always the same compile errors for the declaration: error C2059: syntax error : 'string' error C2059: syntax error : 'string' I tried to declare them like: class CMachine_financial_information : public CDialog { // Construction public: CMachine_financial_information(CWnd* pParent = NULL, CString maquina=""); // standard constructor // Dialog Data //{{AFX_DATA(CMachine_financial_information) enum { IDD = IDDU_MACHINE_FINANCIAL_INFORMATION }; CListCtrl m_lstcFinanceiro; CString m_static_tempo; CString m_static_collected_money; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMachine_financial_information) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL public: LVITEM lvi; SortInfo m_SortInfo; CCtrlSort m_CtrlSort; ----> _RecordsetPtr pRst("ADODB.Recordset"); <------ ----> _bstr_t strConn("DRIVER={Microsoft Access Driver <------(*.mdb)};DBQ=proteres.mdb"); // Implementation protected: //{{AFX_MSG(CMachine_financial_information) virtual BOOL OnInitDialog(); afx_msg void OnSelchangecomboperiod(); virtual void OnCancel(); afx_msg void Oncancel(); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: void dinheirocofre(CString, int); void enchelistctrl(CString); CString machine; }; Can anyone help me with this problem? Thank you in advance

    N 1 Reply Last reply
    0
    • R RuiSantiago

      Hi! I'm working on a application that uses MSAccess database, i run SQL commands like : kl.Format("%s%s%s","SELECT Maquina.nicname FROM Maquina WHERE Maquina.maquinaid='", machineid,"'"); pRst->Open((_bstr_t)kl, strConn, adOpenStatic, adLockReadOnly, adCmdText); Therefor, to use this commands i need this two variables : _RecordsetPtr pRst("ADODB.Recordset"); _bstr_t strConn("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=proteres.mdb"); I've been defining them locally in all my functions, but now i was trying to make them global for the all application, or even the same class, but i get always the same compile errors for the declaration: error C2059: syntax error : 'string' error C2059: syntax error : 'string' I tried to declare them like: class CMachine_financial_information : public CDialog { // Construction public: CMachine_financial_information(CWnd* pParent = NULL, CString maquina=""); // standard constructor // Dialog Data //{{AFX_DATA(CMachine_financial_information) enum { IDD = IDDU_MACHINE_FINANCIAL_INFORMATION }; CListCtrl m_lstcFinanceiro; CString m_static_tempo; CString m_static_collected_money; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMachine_financial_information) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL public: LVITEM lvi; SortInfo m_SortInfo; CCtrlSort m_CtrlSort; ----> _RecordsetPtr pRst("ADODB.Recordset"); <------ ----> _bstr_t strConn("DRIVER={Microsoft Access Driver <------(*.mdb)};DBQ=proteres.mdb"); // Implementation protected: //{{AFX_MSG(CMachine_financial_information) virtual BOOL OnInitDialog(); afx_msg void OnSelchangecomboperiod(); virtual void OnCancel(); afx_msg void Oncancel(); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: void dinheirocofre(CString, int); void enchelistctrl(CString); CString machine; }; Can anyone help me with this problem? Thank you in advance

      N Offline
      N Offline
      nlecren
      wrote on last edited by
      #2

      I don't think you can initialize the _bstr_t in the header at least not with that syntax ----> _RecordsetPtr pRst("ADODB.Recordset"); <------ ----> _bstr_t strConn("DRIVER={Microsoft Access Driver <------(*.mdb)};DBQ=proteres.mdb");

      R 1 Reply Last reply
      0
      • N nlecren

        I don't think you can initialize the _bstr_t in the header at least not with that syntax ----> _RecordsetPtr pRst("ADODB.Recordset"); <------ ----> _bstr_t strConn("DRIVER={Microsoft Access Driver <------(*.mdb)};DBQ=proteres.mdb");

        R Offline
        R Offline
        RuiSantiago
        wrote on last edited by
        #3

        Thanks, do you think i should cast them into another data tye, which should be the best option? Thank you

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups