Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
CRecordset rs(db);
    rs.Open(CRecordset::snapshot,SqlStr,CRecordset::readOnly);
    CDBVariant ip;
    //rs.GetFieldValue(ip);
    int Index;
    Index=12;
    rs.GetFieldValue(Index,ip);



I am using the above code. But rs.GetFieldValue gives exception. I want to take the ip address from the database where it is stored as varchar in database. Please help me.
Posted
Updated 29-Apr-11 19:32pm
v2

"http://www.codeproject.com/KB/database/caaadoclass1.aspx#GetFieldValue"
go through this links this will help u
 
Share this answer
 
CADODatabase* pAdoDb = new CADODatabase();
CString strConnection = "";
strConnection = _T("Provider=MSDASQL;"
"PersistSecurityInfo=False;Trusted_Connection=Yes
Data Source=Access Sql Server;catalog=sampledb");
if(pAdoDb->Open((LPCTSTR)strConnection))
{
CString strQry = _T("");
int numRecords;
strQry.Format(_T("sp_StoreClientFields_ps '%s', %d"),
(LPCTSTR)strParam1, nParam2);
CADORecordset* pRs = new CADORecordset(pAdoDb);
if(!pRs->Open((LPCTSTR)strQry))
{
delete pRs;
delete pAdoDb;
return FALSE
}
numRecords = pRs->GetRecordCount();
while(!pRs->IsEof())
{
CString strVal = _T("");
int nVal = 0;
//Get Numeric Field Value
pRs->GetFieldValue("NumField1", nVal)
//Get String Field Data
pRs->GetFieldValue("StrField..", strVal)
DoSomething(nVal, strVal);
pRs->MoveNext();
}
pRs->Close();
}
else
return FALSE;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900