Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC8.0
 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 29-Apr-11 20:17pm
Edited 29-Apr-11 20:32pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

"http://www.codeproject.com/KB/database/caaadoclass1.aspx#GetFieldValue"
go through this links this will help u
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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;
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 30 Apr 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100