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. sql

sql

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpquestion
3 Posts 3 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.
  • D Offline
    D Offline
    danag
    wrote on last edited by
    #1

    When ruuning my exe, i am getting a 'syntax error in my SQL statemnt'. Here is the code form where the error is coming?? void CMgen1View::LoadListbox() { CMgen1Doc* pDoc = GetDocument(); CListBox* pLB = (CListBox*) GetDlgItem(IDC_LIST1); CMgen1Set sect(&pDoc->m_database); sect.m_strFilter = "InstructorID = '366'"; sect.Open(NULL, _T( "Select * from Section WHERE sect.m_strFilter" )); pLB->ResetContent(); while(!sect.IsEOF()) { CString str; str.Format(_T("%d %d"),sect.m_CourseID , sect.m_SectionNo); pLB->AddString(str); } }

    B S 2 Replies Last reply
    0
    • D danag

      When ruuning my exe, i am getting a 'syntax error in my SQL statemnt'. Here is the code form where the error is coming?? void CMgen1View::LoadListbox() { CMgen1Doc* pDoc = GetDocument(); CListBox* pLB = (CListBox*) GetDlgItem(IDC_LIST1); CMgen1Set sect(&pDoc->m_database); sect.m_strFilter = "InstructorID = '366'"; sect.Open(NULL, _T( "Select * from Section WHERE sect.m_strFilter" )); pLB->ResetContent(); while(!sect.IsEOF()) { CString str; str.Format(_T("%d %d"),sect.m_CourseID , sect.m_SectionNo); pLB->AddString(str); } }

      B Offline
      B Offline
      Bill Wilson
      wrote on last edited by
      #2

      The problem is in your sql statement "Select * from Section WHERE sect.m_strFilter" The SQL server doesn't know what sect.m_strFilter means. Try Select * from Section WHERE InstructorID = '366'

      1 Reply Last reply
      0
      • D danag

        When ruuning my exe, i am getting a 'syntax error in my SQL statemnt'. Here is the code form where the error is coming?? void CMgen1View::LoadListbox() { CMgen1Doc* pDoc = GetDocument(); CListBox* pLB = (CListBox*) GetDlgItem(IDC_LIST1); CMgen1Set sect(&pDoc->m_database); sect.m_strFilter = "InstructorID = '366'"; sect.Open(NULL, _T( "Select * from Section WHERE sect.m_strFilter" )); pLB->ResetContent(); while(!sect.IsEOF()) { CString str; str.Format(_T("%d %d"),sect.m_CourseID , sect.m_SectionNo); pLB->AddString(str); } }

        S Offline
        S Offline
        Stefan Pedersen
        wrote on last edited by
        #3

        Replace sect.Open(NULL, _T( "Select * from Section WHERE sect.m_strFilter" )); With sect.Open(NULL, _T(CString("Select * from Section WHERE ") + sect.m_strFilter ));

        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