Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   SQL Problem in C++ if (http://www.go4expert.com/forums/sql-cpp-t19779/)

thnitos 16Oct2009 13:50

SQL Problem in C++ if
 
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!

xpi0t0s 17Oct2009 04:02

Re: SQL Problem in C++ if
 
What error?
Could it be anything to do with the fact that the string hasn't been terminated?

thnitos 18Oct2009 12:56

Re: SQL Problem in C++ if
 
It points in hear about the error:
Code:

if (Edit1-Text == ADOQuery1->SQL_Text ="Select Username From UsrPass Where Username ='name'")
[BCC32 Error] Unit1.cpp(24): E2277 Lvalue required

xpi0t0s 18Oct2009 15:41

Re: SQL Problem in C++ if
 
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?

thnitos 18Oct2009 17:01

Re: SQL Problem in C++ if
 
I'm trying to compare the given username and password in the boxes with these in the database!

xpi0t0s 18Oct2009 19:51

Re: SQL Problem in C++ if
 
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



All times are GMT +5.5. The time now is 15:19.