|
손효철 님이 쓰신 글 :
: 하안인 님이 쓰신 글 :
: : 손효철 님이 쓰신 글 :
: : : 하안인 님이 쓰신 글 :
: : : : 손효철 님이 쓰신 글 :
: : : : : ms-access 에서 mdb를 만들어 query로 접속시 로그네임과 암호를 묻는데
: : : : : 암호를 만들지 않아고 계속 묻는 창이 나오네요
: : : : :
: : : : : datasource dbgrid query 세개만 배치후 sql문을 넣어 주었습니다
: : : : : 맨 처음 1번 db를 열때 암호를 물어보는데 자동으로 암호와 로그네임을
: : : : : 대입하여 열리게 만들려면 어떻게 해야 할까요?
: : : : :
: : : :
: : : : Database1 의 LoginPrompt 값을 false로 해주시면 됩니다.
: : : :
: : : :
: : :
: : : 그러면 database1의 loginprompt는 어디에 있는건가요
: : : 그리고 암호나 로그네임을 넣을려면 어떻게 대입하나요?
: : :
: : : 아래는 소스입니다
: : :
: : : //---------------------------------------------------------------------------
: : :
: : : #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 str1;
: : : str1 = TDateTime::CurrentDateTime().CurrentDate(); // .DateTimeString();
: : :
: : : int room_no;
: : : room_no=100;
: : : Query1->Close();
: : : Query1->SQL->Clear();
: : :
: : : Query1->SQL->Add(" insert into pay ");
: : : Query1->SQL->Add(" (일자,방번호,방형태 ) ");
: : : Query1->SQL->Add(" values('");
: : : Query1->SQL->Add(str1);
: : : Query1->SQL->Add("','123','234') "); //
: : : Query1->ExecSQL(); // ok
: : : // Query1->Close();
: : : // Query1->SQL->Clear();
: : : // Query1->SQL->Add("select * from pay WHERE 일자>=2003-05-15 "); //
: : : // Query1->Open();
: : :
: : : }
: : : //---------------------------------------------------------------------------
: : : void __fastcall TForm1::Button2Click(TObject *Sender)
: : : {
: : : Query1->Close();
: : : Query1->SQL->Clear();
: : : Query1->SQL->Add("select * from pay WHERE 일자>=2003-05-16 "); //
: : : Query1->Open();
: : :
: : : }
: : : //---------------------------------------------------------------------------
: : : void __fastcall TForm1::Button3Click(TObject *Sender)
: : : {
: : : int room_no;
: : : room_no=100;
: : : Query1->Close();
: : : Query1->SQL->Clear();
: : : // Query1->SQL->Add(" select * from table1 "); // ok
: : : Query1->SQL->Add(" select * from pay where 방번호=:room_no "); // ok
: : : Query1->Prepare();
: : : // Query1->ParamByName("room_no")->AsString=Edit1->Text;
: : : Query1->ParamByName("room_no")->AsString=room_no;
: : : if(Query1->Prepared)Query1->Open();
: : :
: : : }
: : : //---------------------------------------------------------------------------
: : : void __fastcall TForm1::FormCreate(TObject *Sender)
: : : {
: : :
: : : }
: : : //---------------------------------------------------------------------------
: :
: :
: : component tab의
: : Query 컴포넌트 옆에 dababase 컴포넌트가 있습니다.
: : 그리고 사용자와 비밀번호 입력은 속성중에 Params라는 것이 있습니다.
: :
: : 일반적으로 paradox나 dbase 가 아닌 access,interbase,ms-sql같은 것은
: : 데이타모듈을 사용해서 연결하는 것이 일반적입니다.
: :
: : 이런 종류는 책의 예제에도 많이 있으니 참고하시면 될겁니다.
: :
:
: [죄송하지만 c++쪽은 초보라서 잘모르겠습니다 ] 예제 좀 부탁드립니다
지금 예제를 만들어 드릴수는 없고 c++builder 샘플(program files\borand\c++builder\sample\casheup
에 있는 예제를 보셔도 됩니다.
:
|