Any help is appreciate with an issue using ADO and getting data from a record set

2 replies
I am trying to get the contents of the password column in a table using ado.
everything works up until I try to get the data - the various ways compile, but the program crashes with the
error at the bottom of this file.

I've tried to rtfm on google and msdn, but my fundamental ignorance of ado is tripping me up,
any help is greatly appreciated.

thanks,
--Jack


Code:
        ADODB::_ConnectionPtr  con = NULL;
        ADODB::_RecordsetPtr   rec = NULL;
     
        // define variables to read the Author field from the recordset
        
        ADODB::FieldPtr        ppassword;
        _variant_t              vpassword;
        char                   spassword[40];
    
    ........
       bstr_t                 sConString("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=;Initial Catalog=ALCustom;Data Source=(local);Integrated Security=SSPI;");;
        bstr_t                 sSQLString;
        
        // create a variable to hold the result to function calls
        
        HRESULT                hr                = S_OK;
        
        // long variable needed for Execute method of Connection object
        
        VARIANT                *vRecordsAffected = NULL;
     
        // create a new instance of an ADO Connection object
        
        hr = con.CreateInstance(__uuidof(ADODB::Connection));
    
        con->Open(sConString, L"sa", L"", -1);

    strQry.Format("SELECT password FROM users WHERE sname = '%s'", strUsername);    
    sSQLString = (bstr_t)strQry;    

    rec = con->Execute(sSQLString,
                       vRecordsAffected,
                       1);
                       
    if (rec==NULL) { *pbValided = 0; return 0; }
    //testing - works
    //*pbValided =1;
    //return 1;


     ppassword = rec->Fields->GetItem("password");
    
    //testing - WORKS!!
    if (ppassword != NULL) 
    {   //ptr ppassword is not null - this works
        //*pbValided =1;
        //return 1;
    }
    else
    {
        *pbValided =0;
         return 0;
    }
 
    vpassword.Clear();
   
        //nothing I try here works - How do I get the password value from the recordset?
    //vpassword = rec->Fields->GetItem("password")->Value; 
    //vpassword = ppassword->GetValue();
    //vpassword = ppassword->Value;
    vpassword =  rec->GetFields()->GetItem("password")->GetValue();
    //testing - failed
    *pbValided =1;
    return 1;
database fields
-- [id]
-- ,[sname]
-- ,[fname]
-- ,[password]
-- ,[email]


error message from dll crashing:
The system has called a custom component and that component has failed and generated an exception. This indicates a problem with the custom component. Notify the developer of this component that a failure has occurred and provide them with the information below.
Component Prog ID:
Server Application ID: {F42CFEE1-FEE6-445B-80F8-5C7F86D17988}
Server Application Instance ID:
{B8F05B72-0B8D-4075-811E-1833781A3940}
Server Application Name: ULTIMUS SERVER
The serious nature of this error has caused the process to terminate.
Exception: E06D7363
Address: 0x77E4BEF7
Call Stack:
kernel32!RaiseException + 0x3c
CustomAuthenticate!_CxxThrowException + 0x39
CustomAuthenticate!_com_raise_error + 0x26
CustomAuthenticate!_com_issue_errorex + 0x7b
CustomAuthenticate!ADODB::Field20::GetValue + 0x74
CustomAuthenticate!VerifyUser + 0x3d0
ultsec!DllGetClassObject + 0x51be
#ado #data #issue #record #set

Trending Topics