Re: RecordsetPtr & Command's Execute() method
From: Val Mazur (group51a_at_hotmail.com)
Date: 02/27/04
- Next message: Val Mazur: "Re: 'Method 'Value' of object '_AccessField' failed"
- Previous message: Val Mazur: "Re: runtime error -2147024769 (8007007f)"
- In reply to: Chris Martin: "RecordsetPtr & Command's Execute() method"
- Next in thread: Chris Martin: "Re: RecordsetPtr & Command's Execute() method"
- Reply: Chris Martin: "Re: RecordsetPtr & Command's Execute() method"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 26 Feb 2004 22:53:29 -0500
Hi Chris,
Do you want to say that you do not like recordcount -1? If yes, then it is
expected result in your case, because recordset is read-only, forward-only
and provider is not capable to return actual record count in this case, but
recordset is opened and you could use it. Check next KB for more information
http://support.microsoft.com/default.aspx?scid=kb;en-us;194973
-- Val Mazur Microsoft MVP "Chris Martin" <nospam@please11111.net> wrote in message news:o_x%b.130127$jk2.542397@attbi_s53... >I am trying to get back data from a "SELECT" query, and am having trouble > doing anything with the RecordsetPtr returned from a Command's Execute() > method. The docs say: > >> The returned Recordset object is always a read-only, forward-only cursor. > > Am I doing something incorrect in accessing the data from this Recordset? > I > have gotten SELECT queries to work using Recordset's Open() method, but I > wanted to use the Command's Execute() instead. > > If there is a good reason for using a different method, please explain. > > /* code simplified for brevity */ > _ConnectionPtr m_pConnection; > _CommandPtr m_pCommand; > _RecordsetPtr pRs; > > m_pConnection.CreateInstance(__uuidof(Connection)); > m_pCommand.CreateInstance(__uuidof(Command)); > > m_pConnection->Open(m_strConn, lpstrUserID, lpstrPword, NULL); > > m_pCommand->ActiveConnection = m_pConnection; > m_pCommand->CommandText = "SELECT * FROM Customers"; > > pRs = m_pCommand->Execute(NULL, NULL, adCmdText); > > long count = pRs->GetRecordCount(); // returns -1 > _bstr_t str = pRs->GetString(adClipString, 1, ",", "\n", ""); // returns > garbage > /* end */ > > TIA, > C. Martin > >
- Next message: Val Mazur: "Re: 'Method 'Value' of object '_AccessField' failed"
- Previous message: Val Mazur: "Re: runtime error -2147024769 (8007007f)"
- In reply to: Chris Martin: "RecordsetPtr & Command's Execute() method"
- Next in thread: Chris Martin: "Re: RecordsetPtr & Command's Execute() method"
- Reply: Chris Martin: "Re: RecordsetPtr & Command's Execute() method"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|