DataBase variables
-
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
-
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
-
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");
Thanks, do you think i should cast them into another data tye, which should be the best option? Thank you