RE: Inserted Identity Values in SQL 2005
- From: changliw@xxxxxxxxxxxxxxxxxxxx (Charles Wang[MSFT])
- Date: Wed, 20 Jun 2007 12:59:44 GMT
Hi David,
I just wrote a sample for testing your issue, however since the merge
replication will not be established until tommorrow. I may delay the test
one day and will let you know the result tommorrow.
My test sample code is as following and worked fine at my local computer:
#import "msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
#include <stdio.h>
void execute(LPWSTR strCn,long& nId)
{
CoInitialize(NULL);
try
{
_ConnectionPtr cn(_T("ADODB.Connection"));
_RecordsetPtr rs(_T("ADODB.Recordset"));
_bstr_t strMissing(L"");
cn->Open(strCn,
strMissing, _T(""),
adConnectUnspecified);
rs->Open(_T("INSERT INTO TASK(TASKNAME,TASKDESC)
VALUES('TEST','TEST')"), _variant_t((IDispatch *)cn,true),
adOpenStatic,adLockOptimistic,adCmdText);
rs->Open(_T("SELECT TaskId From Task WHERE TaskId=@@IDENTITY"),
_variant_t((IDispatch *)cn,true), adOpenStatic,adLockOptimistic,adCmdText);
nId = rs->Fields->Item[_T("TaskId")]->Value;
rs->Close();
cn->Close();
}
catch (_com_error &e)
{
nId=-1;
}
::CoUninitialize();
}
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
.
- References:
- Inserted Identity Values in SQL 2005
- From: David
- RE: Inserted Identity Values in SQL 2005
- From: Charles Wang[MSFT]
- RE: Inserted Identity Values in SQL 2005
- From: David
- Inserted Identity Values in SQL 2005
- Prev by Date: Re: ADODB Recordset and Connection
- Next by Date: Re: French, German, Italian SQL Query via ADO
- Previous by thread: RE: Inserted Identity Values in SQL 2005
- Next by thread: RE: Inserted Identity Values in SQL 2005
- Index(es):
Relevant Pages
|
|