Helllo Every One.
I am facing a problem i dont know much about using database in ISAPI Application i have wriiten a method 2 ValidateUser in ISAPI Application i want to access databse from ISAPI but i could't do so


The Code is as under,
I have imported msado15.dll
and initialize the com object


void CServerDLLExtension:: ValidateUser(CHttpServerContext* pCtxt, LPCTSTR username, LPCSTR password)
{
*pCtxt << "First Name : " << username <<"<br>";
*pCtxt << "Last Name : " << password <<"<br>";

*pCtxt << "Here it is going to try to connect to DATABASE <br>";

//Interacting with the dat abse.


try
{
_ConnectionPtr pConn;
HRESULT hr = pConn.CreateInstance (__uuidof (Connection));

if (FAILED (hr))
{
*pCtxt << WriteError("Can't create intance of Connection");
return;
}

if (FAILED (pConn->Open (_bstr_t ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = d:\\BUps\\VDVDB.MDB"),//database is there
_bstr_t (""), _bstr_t (""), adModeUnknown)))
{
//AfxMessageBox ("Can't open datasource");
*pCtxt << WriteError("Can't open datasource");
return;
}



CString strSQL = "SELECT * FROM Administrator;";

_CommandPtr pCommand;
*pCtxt << WriteError(strSQL);
//Till Here there is no error and next command throws exception
pCommand->ActiveConnection = pConn;//Sets the ActiveConnection

*pCtxt << WriteError("Reach Here<br>");
//CString strUserName = username;
//CString strPassword = password;

pCommand->CommandText = _bstr_t(strSQL);//The Query To Execute

_RecordsetPtr pRecordset;
hr = pRecordset.CreateInstance (__uuidof (Recordset));
if (FAILED (hr))
{
*pCtxt << WriteError("Can't create an instance of Recordset");
return;
}

pRecordset->CursorLocation = adUseClient;
pRecordset->Open ((IDispatch *) pCommand, vtMissing, adOpenForwardOnly,
adLockReadOnly, adCmdUnknown);

if(pRecordset->GetadoEOF ())
{
* pCtxt << WriteError("Invalid User Name or Password");
return;
}
else
{
* pCtxt << "Well Come to ISAPI Application";
CString mail = "[email protected]";
//mail = (char *) (_bstr_t) pRecordset->Fields->GetItem ("Email")->Value;
* pCtxt << "<hr>";
* pCtxt << mail;
* pCtxt << "<hr>";
}

}catch(_com_error & e)
{
*pCtxt << WriteError("<hr>Error Here In Try Catch Description Below <br>");
//_bstr_t bstrSource(e.Source());
//*pCtxt << WriteError((char *)bstrSource);

_bstr_t bstrSource (e.Source());
_bstr_t bstrDescription (e.Description());
TRACE ( "Exception thrown for classes generated by #import" );
TRACE ( "\tCode = %08lx\n", e.Error ());
TRACE ( "\tCode meaning = %s\n", e.ErrorMessage ());
TRACE ( "\tSource = %s\n", (LPCTSTR) bstrSource);
TRACE ( "\tDescription = %s\n", (LPCTSTR) bstrDescription);

*pCtxt << WriteError((LPCTSTR) bstrDescription);
return;
}
catch(...)
{
*pCtxt << _T(WriteError("Un Handled Exception"));
}

}



If some one can help me it would be very great 4 me

Thanx Alot in Advance