|
안녕하세요
밑에 소스를 보니 (')문자가 빠진거 같네요..
SQL은 이렇게 되잖아여.~~
select * from aaa where id='zoro' and pwd='몰라' and mail='멜'
그러니까 아래 SQL스트링을 만드실때
String Mem_id="Mem_id='" + Edit1->Text + "'";
이렇게 해야 되지 않을까 생각합니다..
그럼 즐거운 하루 되십시요.~~
시빌더사냥꾼 님이 쓰신 글 :
: 안녕하세요..
:
: 이렇게 질문을 해도 될런지 모르겠네요..일단 죄송하다는 말씀을 드릴게요.
:
: 너무 머리가 아파서요..왜 안되는지 이상해서요..
:
: 한번 보시고 조언 부탁드립니다.
:
: 다름이 아니라 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
:
: 감사합니다...꾸벅.
:
:
|