SQL Problem in C++ if

Discussion in 'C++' started by thnitos, Oct 16, 2009.

  1. thnitos

    thnitos New Member

    Joined:
    Oct 16, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Hi there!
    I have an EditBox and a database witch i rote in Microsoft SQL Server 2008.
    I'm trying to check the text in the editbox with the database!
    I'm doing this because i have form that checks username and password!
    I've wrote this :
    Code:
    if (Edit1->Text == ADOQuery1->SQL->Text = "Select Username From UsrPass
                                                                         Where Username = 'name')
      {
        
      }
    
    but it came out with an error
    I apresiate any help!
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    What error?
    Could it be anything to do with the fact that the string hasn't been terminated?
     
  3. thnitos

    thnitos New Member

    Joined:
    Oct 16, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    It points in hear about the error:
    Code:
    if (Edit1-Text == ADOQuery1->SQL_Text[COLOR=Yellow] [COLOR=Red]=[/COLOR][/COLOR]"Select Username From UsrPass Where Username ='name'")
    
    [BCC32 Error] Unit1.cpp(24): E2277 Lvalue required
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    The statement doesn't make sense, hence the error. But it's one of those statements where you can't tell what exactly is wrong without knowing what you're trying to do. So there's an if, but what are you comparing with what, and why is there an assignment in the middle of the expression?
     
  5. thnitos

    thnitos New Member

    Joined:
    Oct 16, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    I'm trying to compare the given username and password in the boxes with these in the database!
     
  6. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    I would suggest reading the details from the database first, rather than trying to do it in one step.
    Code:
    ADOQuery1->SQL_Text="select..."
    // execute the query
    // fetch, say into variable x
    if (Edit1->Text == x)
    // etc
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice