|
제가 보기에는 쿼리가 공백없이 만들어져서 그런것 같은데요.....
String Where ="where";
String And="and";
이 두부분을 Add 를 시키면 from Table_name 다음에 바로 붙어서 나오니까
쿼리가 제대로 실행이 안되어서 그런것 같네요.
String Where =" where ";
String And=" and ";
이렇게 앞뒤에 공백을 두어서 만들면 될것 같은데요....
홍성진 님의 말대로 쿼리가 제대로 생성이 되는지 화면에 출력해보면 디버깅을
쉽게 하실 수 있을 것 같네요....
이상 빌더 초보 도난경보기였습니다.
시빌더사냥꾼 님이 쓰신 글 :
: 안녕하세요..
:
: 이렇게 질문을 해도 될런지 모르겠네요..일단 죄송하다는 말씀을 드릴게요.
:
: 너무 머리가 아파서요..왜 안되는지 이상해서요..
:
: 한번 보시고 조언 부탁드립니다.
:
: 다름이 아니라 DB에서 회원으로 가입된 아이디의 검색 값을 가져오는 방법입니다.
:
: 그런데 안되는 군요..
:
: 소스입니다..참고하시고요..틀린 부분 지적좀 해주시면 감사하겠습니다.
: ------------------소스-----------------
: Unit.cpp (유닛 부분)
:
: //---------------------------------------------------------------------------
:
: #include <vcl.h>
: #pragma hdrstop
:
: #include "Unit1.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner)
: : TForm(Owner)
: {
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
: String Where ="where";
: String And="and";
: String Mem_id="Mem_id=" +Edit1->Text;
: String Mem_passwd="Mem_passwd=" +Edit2->Text;
: String Mem_email="Mem_email=" +Edit3->Text;
:
: Query1->Close();
: Query1->SQL->Clear();
: Query1->SQL->Add("select * from dbo.login");
:
: if((Edit1->Text !="") || (Edit2->Text !="") || (Edit3->Text !=""))
: {
: Query1->SQL->Add(Where);
:
: if(Edit1->Text !="")
: {
: Query1->SQL->Add(Mem_id);
: Query1->SQL->Add(And);
: }
:
: if(Edit2->Text !="")
: {
: Query1->SQL->Add(Mem_passwd);
: Query1->SQL->Add(And);
: }
:
: if(Edit3->Text !="")
: {
: Query1->SQL->Add(Mem_email);
: Query1->SQL->Add(And);
: }
:
: Query1->SQL->Delete(Query1->SQL->Count -1);
: }
:
: Query1->Open();
: }
:
: //---------------------------------------------------------------------------
: endif
:
: Unit.h(헤더 파일)
:
: //---------------------------------------------------------------------------
:
: #ifndef Unit1H
: #define Unit1H
: //---------------------------------------------------------------------------
: #include <Classes.hpp>
: #include <Controls.hpp>
: #include <StdCtrls.hpp>
: #include <Forms.hpp>
: #include <Db.hpp>
:
: #include <DBGrids.hpp>
: #include <DBTables.hpp>
: #include <Grids.hpp>
: //---------------------------------------------------------------------------
: class TForm1 : public TForm
: {
: __published: // IDE-managed Components
: TLabel *Label1;
: TLabel *Label2;
: TLabel *Label3;
: TEdit *Edit1;
: TEdit *Edit2;
: TEdit *Edit3;
: TButton *Button1;
: TDataSource *DataSource1;
: TQuery *Query1;
: TDBGrid *DBGrid1;
: void __fastcall Button1Click(TObject *Sender);
: private: // User declarations
: public: // User declarations
: String Mem_id, Mem_passwd, Mem_email;
: __fastcall TForm1(TComponent* Owner);
: };
: //---------------------------------------------------------------------------
: extern PACKAGE TForm1 *Form1;
: //---------------------------------------------------------------------------
: #endif
:
: 감사합니다...꾸벅.
:
:
|