Thread View: borland.public.cppbuilder.database.multi-tier
2 messages
2 total messages
Started by George Wei
Fri, 11 Aug 2000 00:00
What's wrong with my codes?
Author: George Wei
Date: Fri, 11 Aug 2000 00:00
Date: Fri, 11 Aug 2000 00:00
80 lines
3017 bytes
3017 bytes
I have implemented an application server in both C++ Builder 5 & Delphi 5.
The only difference between them is the codes of an interface's
implementation.
The following are the same steps in CB5 & D5:
1. New an ActiveX Library;
2. New a Remote Data Module (name it as MIDASServer);
3. Put an ADOConnection(ADOConnection1), 2 ADOQuerys(ADOQuery1, ADOQuery2),
a DataSetProvider(DataSetProvider1) in MIDASServer;
4. Open Type Library editor, new a funtion named VerifyPassword of
interface IMIDASServer as the following:
HRESULT _stdcall VerifyPassword([in] BSTR Username, [in] BSTR Password,
[out, retval] VARIANT * RetVal );
5. The following implementation of function VerifyPassword is different in
CB5 & D5:
//---In CB5---
STDMETHODIMP TMIDASServerImpl::VerifyPassword(BSTR Username, BSTR Password,
TVariant* RetVal)
{
AnsiString S;
if(m_DataModule->ADOQuery2->Active==true)
m_DataModule->ADOQuery2->Close();
m_DataModule->ADOQuery2->Parameters->ParamByName("Username")-
>Value=UpperCase(Username);
m_DataModule->ADOQuery2->Open();
S=m_DataModule->ADOQuery2->FieldByName("Password")->AsString;
m_DataModule->ADOQuery2->Close();
if(S==AnsiString(Password))
return S_OK;
else
return E_FAIL;
}
//---In D5---
function TMIDASServer.VerifyPassword(const Username,
Password: WideString): OleVariant;
var
S : AnsiString;
begin
if(ADOQuery2.Active=true) then
ADOQuery2.Close;
ADOQuery2.Parameters[0].Value:=UpperCase(Username);
ADOQuery2.Open;
S:=ADOQuery2.Fields[0].AsString;
ADOQuery2.Close;
if(S=AnsiString(Password)) then
result:=S_OK
else
result:=E_FAIL;
end;
At last, I implement a procedure in a client program in D5 to call these 2
server's function VerifyPassword as the following:
procedure TFormSecurity.btnOKClick(Sender: TObject);
var
hr:HRESULT;
begin
if(DCOMConnection1.Connected=false) then
DCOMConnection1.Connected:=true;
hr:=DCOMConnection1.AppServer.VerifyPassword(edtUsername.Text,edtPassword
.Text);
if(SUCCEEDED(hr)) then
ShowMessage('Succeeded.')
else
ShowMessage('Failed.');
end;
The problem is, when the both servers return S_OK, the client can show the
message 'Succeeded.' correctly; when the servers tries to return E_FAIL,
the client shows the message 'Failed.' correctly when calling the D5
version, but it gets the following exception info:
Project Client.exe raised exception class EOleException with
message 'Cannot specified error'. ...
What's wrong with my codes of the CB5 version? Thanks to any help.
Re: What's wrong with my codes?
Author: George Wei
Date: Sat, 12 Aug 2000 00:00
Date: Sat, 12 Aug 2000 00:00
10 lines
809 bytes
809 bytes
gweii@21cn.com (George Wei) wrote in <8n0eql$fm65@bornews.borland.com>: Sorry for something is wrong in my last letter: The wrong line is: >...but it gets the following exception: The correct line has to be: >...but it gets the following exception info from the CB5 version: George
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads