Home > Software engineering >  GetCollect took the empty field value (), it is an error directly, also how to use the val. Vt. Judg
GetCollect took the empty field value (), it is an error directly, also how to use the val. Vt. Judg

Time:11-02

This
1 _variant_t TheValue;
2 TheValue=https://bbs.csdn.net/topics/m_Adoconn.m_pRecordset-> GetCollect (" gw ");
3 the if (TheValue vt!=VT_NULL)
Gw 4=TheValue. BstrVal;
5 m_listLCdata. SetItemText (0, 7, gw);

Some people say that if the gw field value is empty, judgment, but when the field value is empty, GetCollect (" gw "statement) is an error, collapsed and was running less than if statements, change how to modify, please answer, thank you!

CodePudding user response:

TheValue=https://bbs.csdn.net/topics/m_Adoconn.m_pRecordset-> GetCollect (_bstr_t (" gw "));

CodePudding user response:

Read the cursor is suitable for determining if a m_pRecordset first eof, and then you can read
M_pRecordset - & gt; MoveFirst ();
while(! M_pRecordset - & gt; AdoEOF)
{
//your code
,,,
_variant_t TheValue;
TheValue=https://bbs.csdn.net/topics/m_Adoconn.m_pRecordset-> GetCollect (" gw ");
If (TheValue vt!=VT_NULL)
Gw=TheValue. BstrVal;
M_listLCdata. SetItemText (0, 7, gw);

M_pRecordset - & gt; MoveNext ();
}

CodePudding user response:

M_pRecordset also need to empty the pointer

CodePudding user response:

reference xiaohuh421 reply: 3/f
m_pRecordset this pointer also need to empty

This may be the biggest

CodePudding user response:

Directly in the SQL statement, filtering out of the empty, empty, you value has no meaning,

CodePudding user response:

2 l, positive solution, every time before the read data from the record must be to determine whether a record has been at the end of the day (that is, empty)

CodePudding user response:

reference 4 floor luxiaolai861227 response:
Quote: reference xiaohuh421 reply: 3/f

Also need to empty m_pRecordset this pointer

The most likely

I give the five statements have been in the while loop, has determined there is data to enter circulation data, so this place is not the issue

CodePudding user response:

refer to the second floor lis2012 response:
read cursor is suitable for determining if a m_pRecordset first eof, and then you can read
M_pRecordset - & gt; MoveFirst ();
while(! M_pRecordset - & gt; AdoEOF)
{
//your code
,,,
_variant_t TheValue;
TheValue=https://bbs.csdn.net/topics/m_Adoconn.m_pRecordset-> GetCollect (" gw ");
If (TheValue vt!=VT_NULL)
Gw=TheValue. BstrVal;
M_listLCdata. SetItemText (0, 7, gw);

M_pRecordset - & gt; MoveNext ();
}

My original program is to judge is not empty:
M_pRecordset=m_Adoconn. GetRecordSet (SQL) (_bstr_t);
While (m_pRecordset - & gt; AdoEOF==0)
{
//will be the records in the recordset fields added to the List Control Control
Cstrings Conid, lc;
_variant_t TheValue;
TheValue=https://bbs.csdn.net/topics/m_Adoconn.m_pRecordset-> GetCollect (" gw ");
If (TheValue vt!=VT_NULL)
Gw=TheValue. BstrVal;
M_listLCdata. SetItemText (I, 7, gw);
}
, of course, is the first judgment is not empty again into the loop access, my question is to get the data, if a line of a field is empty, such as gw TheValue=https://bbs.csdn.net/topics/m_Adoconn.m_pRecordset-> GetCollect (" gw "); The other direct error, can not execute the sentence if judgment, understand?

CodePudding user response:

The collapse should be thrown exception, try _com_error exception handling

CodePudding user response:

In the while you judge the statements and your statement record of the data were obtained using is not the same, and your MoveNext () is used in the recordset, best unified
While ( m_pRecordset - & gt; AdoEOF==0)
TheValue=https://bbs.csdn.net/topics/ m_Adoconn. M_pRecordset - & gt; GetCollect (" gw ");

And in GetCollect (" gw ") that best GetCollect (_variant_t (" gw "))

CodePudding user response:

What's wrong, don't you say, error occurs after the breakpoint inside look will always find something you
Now what also don't say you just said is wrong, let a person to help you "guess", and then you cheated foolishly
Didn't even know where to the nature of the error, will happen the same mistake next time and you must forget the lesson

CodePudding user response:

reference 5 floor nanfeiyannan reply:
directly in the SQL statement, screening out of the empty, empty, you value has no meaning.

Nonsense, the somebody else say field is empty

CodePudding user response:

This I also met, mainly because, you choose the SQL data is datatime, when the data is empty, you write will go wrong.

CodePudding user response:

_variant_t TheValue;
TheValue=https://bbs.csdn.net/topics/m_Adoconn.m_pRecordset-> GetCollect (" gw ".) GetVARIANT ();
If (TheValue vt!=VT_NULL)
Gw=TheValue. BstrVal;
M_listLCdata. SetItemText (0, 7, gw);

This is ok,. GetVARIANT ();

CodePudding user response:

Attention! I also appeared such problems

CodePudding user response:

The building Lord, I tried,
_variant_t TheValue;
TheValue=https://bbs.csdn.net/topics/m_Adoconn.m_pRecordset-> GetCollect ((_variant_t) "gw"); - increased (_variant_t)
If (TheValue vt!=VT_NULL)
Gw=(*) would be (_bstr_t) TheValue; -- here use TheValue. BstrVal complains on my side
M_listLCdata. SetItemText (0, 7, gw);

Then I tested, the data in the record to the space-time not an error
  • Related