Click here to Skip to main content
15,912,507 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: good programmer Pin
Stephan A.17-Sep-10 23:27
Stephan A.17-Sep-10 23:27 
JokeRe: good programmer Pin
Richard MacCutchan17-Sep-10 7:37
mveRichard MacCutchan17-Sep-10 7:37 
GeneralRe: good programmer Pin
CPallini17-Sep-10 10:25
mveCPallini17-Sep-10 10:25 
GeneralRe: good programmer Pin
AmbiguousName17-Sep-10 22:19
AmbiguousName17-Sep-10 22:19 
AnswerRe: good programmer Pin
Emilio Garavaglia18-Sep-10 21:01
Emilio Garavaglia18-Sep-10 21:01 
QuestionLoad balance problem Pin
yu-jian16-Sep-10 16:30
yu-jian16-Sep-10 16:30 
AnswerRe: Load balance problem Pin
Garth J Lancaster16-Sep-10 23:59
professionalGarth J Lancaster16-Sep-10 23:59 
QuestionOLEDB CAccessor with CMultipleResults what am I doing wrong. Pin
Spawn@Melmac16-Sep-10 12:35
Spawn@Melmac16-Sep-10 12:35 
The problem:

I am using an accessor to INSERT into a table but this does return a value so I am using two commands to find out the ID of what was just inserted or at least that is the idea. I get DB_E_ERRORSINCOMMAND so if anyone can point me to where I am going wrong then you can save both my sanity and my hair...

This is the accessor class from the test application I have been troubleshooting against.
class CDBEvtRawInsert
{
public:
	// Data Elements
	int		f_Direction;
	int		f_HubID;
	TCHAR		f_RawEvent[1400];
	LARGE_INTEGER	f_RawEventID;

	BEGIN_COLUMN_MAP(CDBEvtRawInsert)
		COLUMN_ENTRY(1, f_RawEventID)
	END_COLUMN_MAP()

	// Parameter binding map
	BEGIN_PARAM_MAP(CDBEvtRawInsert)
		SET_PARAM_TYPE(DBPARAMIO_INPUT)
		COLUMN_ENTRY(1, f_Direction)
		COLUMN_ENTRY(2, f_HubID)
		COLUMN_ENTRY(3, f_RawEvent)
	END_PARAM_MAP()

	DEFINE_COMMAND_EX(CDBEvtRawInsert, L" \
							INSERT INTO [RawEvent] ([TimeStamp],[Direction],[Hub],[RawEvent])	\
							VALUES (GETDATE(),?,?,?);SELECT @@IDENTITY AS RawEventID")
};


This is an extract from the function

CString szValue = _T("test");
HRESULT hr = E_FAIL;
CCommand<CAccessor<CDBEvtRawInsert >,CRowset, CMultipleResults > rsEvtRawInsert;

wcscpy_s(rsEvtRawInsert.f_RawEvent, szValue.GetLength()*2, szValue);
rsEvtRawInsert.f_Direction = 1;
rsEvtRawInsert.f_HubID = 0;
hr = rsEvtRawInsert.Open(theApp.m_oDB.session);         // <<==== fails here
if(S_OK == hr)
{
    DBROWCOUNT out;
    hr = rsEvtRawInsert.GetNextResult(&out);


I know the SQL is ok as I have tested it in SQL Management Studio on the same DB this code is using. Also if I make it a single recordset by removing the SELECT @@IDENTITY that works too.
If you have an alternative suggestion which would achieve the same result then I am all ears.

Thank you for reading this far.
Alan

Questiongetting names of the lines in TAPI?? Pin
AmbiguousName16-Sep-10 7:53
AmbiguousName16-Sep-10 7:53 
QuestionRe: getting names of the lines in TAPI?? Pin
David Crow16-Sep-10 10:39
David Crow16-Sep-10 10:39 
QuestionTerminating Threads! [modified] Pin
Caslen16-Sep-10 3:21
Caslen16-Sep-10 3:21 
AnswerRe: Terminating Threads! Pin
Cool_Dev16-Sep-10 5:26
Cool_Dev16-Sep-10 5:26 
GeneralRe: Terminating Threads! Pin
Roger Allen16-Sep-10 5:50
Roger Allen16-Sep-10 5:50 
GeneralRe: Terminating Threads! Pin
Luc Pattyn16-Sep-10 6:14
sitebuilderLuc Pattyn16-Sep-10 6:14 
GeneralRe: Terminating Threads! Pin
Caslen16-Sep-10 5:59
Caslen16-Sep-10 5:59 
GeneralRe: Terminating Threads! Pin
Chris Losinger16-Sep-10 6:02
professionalChris Losinger16-Sep-10 6:02 
GeneralRe: Terminating Threads! Pin
Caslen16-Sep-10 6:08
Caslen16-Sep-10 6:08 
AnswerRe: Terminating Threads! Pin
David Crow16-Sep-10 5:53
David Crow16-Sep-10 5:53 
GeneralRe: Terminating Threads! Pin
Caslen16-Sep-10 6:04
Caslen16-Sep-10 6:04 
GeneralRe: Terminating Threads! Pin
David Crow16-Sep-10 6:45
David Crow16-Sep-10 6:45 
GeneralRe: Terminating Threads! Pin
Caslen16-Sep-10 22:31
Caslen16-Sep-10 22:31 
QuestionRe: Terminating Threads! Pin
David Crow17-Sep-10 2:56
David Crow17-Sep-10 2:56 
AnswerRe: Terminating Threads! Pin
Caslen17-Sep-10 3:04
Caslen17-Sep-10 3:04 
GeneralRe: Terminating Threads! Pin
David Crow17-Sep-10 3:09
David Crow17-Sep-10 3:09 
AnswerRe: Terminating Threads! Pin
Roger Allen16-Sep-10 5:54
Roger Allen16-Sep-10 5:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.