Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Given the following ADO code segment, how does one retrieve the result of the query.Must one use a variant what?

C++
MyCommandPtr->CommandType = adCmdText;
MyCommandPtr->CommandText = _bstr_t(_T("SELECT IDENT CURRENT ('MyTable')"));
MyRecordsetPtr = MyCommandPtr->Execute(NULL,NULL,adCmdText);

/*Should the next step be
_variant_t  vResult = MyRecordsetPtr->Fields->Item[1]->Value;
int iResult = (int)vResult;*/
Posted
Updated 28-Feb-14 4:43am
v2
Comments
PIEBALDconsult 28-Feb-14 10:49am    
Can you examine the type with a debugger?
Gbenbam 2-Mar-14 9:15am    
This is a fictitious example.What quest is: what is the next step?Is the specified step the appropriate next step?
CHill60 19-Mar-14 11:39am    
See Solution 1 and my comment to it. You may also find this link useful http://www.cprogramming.com/tutorial/ado_sql_introduction.html[^]

I'd suggest you to start here:
Visual C++ ADO Programming[^]
Data Access Using ADO.NET (C++/CLI)[^]
ADO Code Examples in Visual C++[^]

I hope you'll find waht you're looking for ;)
 
Share this answer
 
Assuming the query succeeded and returned at least one record, the answer is yes. On the other hand, I've seldom seen a SELECT without FROM.
Run the query outside your development environment (e.g., using SQL+, Management Studio, or the equivalent for your RDBMS).
I don't know which RDBMS you're querying against. Not SQL Server, I suppose: neither Oracle, which, as far as I remember, requires you to select FROM DUAL whenever you don't have the data in a real table.


Hope this helps,
Pablo.

Updated - striked the irrelevant.
 
Share this answer
 
v2
Comments
CHill60 19-Mar-14 11:39am    
The OP should have SELECT IDENT_CURRENT (i.e. the underscore is missing) - and this has been in SQL Server since at least Ver 2000 ... see http://technet.microsoft.com/en-us/library/ms175098.aspx[^]
However you answered the OP's question ("Yes") so I don't know why you were downvoted
Gbenbam 19-Mar-14 12:00pm    
Perhaps you should see this
http://technet.microsoft.com/en-us/library/ms175098.aspx

And this:

http://technet.microsoft.com/en-us/library/ms190315.aspx

So what is your updated answer in the light of those.I eagerly await your response.
Pablo Aliskevicius 19-Mar-14 14:22pm    
Striked out the irrelevant. Still hope to help.

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