|
Thanks,
now I know the way to investigate the issue
|
|
|
|
|
Hi friends,
Below line contain my code.I m writting data into the text file.i have acess database and i write this databse into text file format. my access databse table contain 99 records and i m using CDaoRecordset MoveNext() to get next record data.Problem is that i get record till 18 its ok but after that i get 20 position record and afterthat i get 19 position record.then i get 26 to 30 position record and then i get 21 to 25 record data.But data in the database table is sequentially.So why this problem will occour i wont understand.
Plz help me..
m_pRecordSet = new CDaoRecordset(m_pDatabase);
CString strTablename = _T("pdpstate");
m_pRecordSet->Open(dbOpenTable,strTablename);
int nRecordCnt = m_pRecordSet->GetRecordCount();
int nFieldCnt = m_pRecordSet->GetFieldCount();
CDaoFieldInfo cTempdaoFieldInfo;
CString csSetID,csFieldStr;
CStdioFile cTestFile;
cTestFile.Open(_T("d:\\Jitu45.txt"),CStdioFile::modeCreate | CStdioFile::modeWrite);
for(int nfCnt = 0; nfCnt < nFieldCnt; nfCnt++)
{
m_pRecordSet->GetFieldInfo(nfCnt,cTempdaoFieldInfo);
cTestFile.WriteString(cTempdaoFieldInfo.m_strName);
cTestFile.WriteString(_T(","));
}
cTestFile.WriteString(_T("\n"));
while(!m_pRecordSet->IsEOF())
{
COleVariant variantTemp;
//..// Move through fields in current record..
int nFields = m_pRecordSet->GetFieldCount();
for ( int i=0; i < nFields; i++ )
{
variantTemp.Clear();
variantTemp = m_pRecordSet->GetFieldValue(i);
csSetID.Format(_T("%d"),variantTemp.intVal);
cTestFile.WriteString(csSetID);
cTestFile.WriteString(_T(","));
}
cTestFile.WriteString(_T("\n"));
m_pRecordSet->MoveNext();
}
cTestFile.Close();
|
|
|
|
|
What about an ORDER BY clause in the query?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ORDER BY can be achieved by setting the COLUMN_NAME by which you want to sort the records to the "m_strSort" member of the CDaoRecordset class.
|
|
|
|
|
Hi All
How can i convert _variant_t to CString?
|
|
|
|
|
I suppose you need the string representation of the _variant_t value.
You've to properly format a CString object, depending on the value of the vt member of the encapsulated VARIANT struct. For instance
CString str;
_variant_t v1;
v1 = 0.53;
switch (v1.vt)
{
case VT_R8:
str.Format(_T("%g"), v1.dblVal);
break;
}
MessageBox(str, _T("Variant value"));
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Noooooo - you don't need to bother with that - there's a VariantChangeType function that'll do that for you when you convert a VARIANT to a BSTR.
And even more conveniently, the combination of _variant_t extractor operators and CString constructors will do all that for you. A simple assignment of _variant_t to CString is all that's needed...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Nice to know .
What about _variant_t containing arrays?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: What about _variant_t containing arrays?
Use CComSafeArray[^].
_variant_t v;
CComSafeArray<char, VT_UI1> sa(V_ARRAY(&v));
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for responce.I hava a biray type data in _variant_t.
_variant_t v1;
v1=(54 '6',53 '5',52 '4',54 '6',52 '4',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
Can i convert these values in CString or not.
Origal values is"65464".
Plz help me
|
|
|
|
|
What is v1.vt value?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In VS2008, this should do the job...
_variant_t v;
CString s = v;
CString has assignment operator and constructor overl;oads that take a const VARIANT& . _variant_t has an extrractor that returns a VARIANT .
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
I (and Microsoft, who wrote the _variant_t and CString code) have helped you - you just assign the _variant_t to the CString - what more do you want?!?!?!?!?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
See what happen.
_variant_t vtValue;
vtValue = m_pRset->Fields->GetItem("Bianry")->GetValue();
CString b=vtValue;
output is b = "??4"
when i copy the vtValues at the time of debug then i got values
safearray of UI1 = [20](54 '6',53 '5',52 '4',54 '6',52 '4',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
Any more information if you nedd then i will give you.
|
|
|
|
|
As it's an array, VariantChangeType's not going to work. So, I'd suggest the code below.
I'm assuming you want to access the non-null characters of the array and make them into a string?
CComSafeArray<char, VT_UI1> sa(V_ARRAY(&v));
CString s;
for(int index=sa.GetLowerBound();index<=sa.GetUpperBound()&&sa[index];++index)
{
s+=sa[index];
}
[edit] You'll also need to #include atlsafe.h and oleauto.h [/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
What do you think about this VT_UI1 SAFEARRAY to CStringA conversion method?
BSTR b;
BstrFromVector(pSA,&b);
CStringA s = (LPCSTR)b;
Best Wishes,
-David Delaune
|
|
|
|
|
New to me - that'll teach me to do what I've told many other people to do and read the documentation
And of course it'll work with wide CStrings as well.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thanks it's working for me.
|
|
|
|
|
Hi rdop,
The following snippit will work on all Microsoft compilers:
_variant_t v;
v = 3.141;
::VariantChangeType(&v, &v, 0, VT_BSTR);
CString s = (LPTSTR)(_bstr_t)v.bstrVal;
Best Wishes,
-David Delaune
|
|
|
|
|
Hi vc++ programmers,
I am migrating my project from vs-2003 to vs-2008...I am getting bolow linking error when i am building my project.
errorfwstsrv.obj : error LNK2019: unresolved external symbol "public: int __thiscall DomIssuerInfo::HasSurvFeeBillableDebt(class DblDateTime const &,class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const &)
I have set the linker settings.When i am saying project Settings->linker->General->Use library dependencies:YES,i am getting above error.. If i say NO i am getting the corresponding library also added with the above error.I have set all my libraries through linker settings...but notknow why i am getting....................please give some remeby to this.... thanks in advance........
|
|
|
|
|
CString changed between VS2003 and VS2008 - have the libraries been recompiled with VS2008?
Presuming you know which library that function should be defined in, you could use Dependency Walker to check if the library does actually export that function.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
HI Thankyou for your reply,I have recompiled again and again...my project is working in release mode.But when comes to debug mode it is giving linking errors(362) of the same type.....
And i have also tried to giv the library paths through #pragma comment(lib,"..."),,,but i am not exactly getting where should i include this pragma directive.....
can you further help?
modified on Tuesday, September 15, 2009 7:04 AM
|
|
|
|
|
OK - you sdee where you said 'I have set the linker settings.' in your first settings - you realise that Release and Debug modes have different settings?
Vetukuri Raju wrote: And i have also tried to giv the library paths through #pragma comment(lib,"...")
You can put it any where - I usually put the #pragma right after the #include that brings in that library's header file.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
No,,,i dinnt find any major differences.....out of 10 libraries it is anable to link three libraries...
My application is succesfully working on vs-2003....i have compared with 2003 debug setting also....
|
|
|
|
|