Stored procedure returning identity value

S

Stanley

Hi,

i am executing an insert stored procedure. This stored procedure returns the
newly created identity value:
id Name
--------------
1 test2
2 test2

If i insert test3 an id with number 3 is created and returned by the stored
procedure. How can i read this value (id 3)?

This is my code for executing de SP:

ADOAdapterObject adapt =
(ADOAdapterObject)thisXDocument.DataObjects["Test"].QueryAdapter;
adapt.Command.ToString();
adapt.Command = "execute TestInsert 0,'test','MyName','01/12/2005'";
adapt.Query();

The adapt.Query() returns void, so it doesn't return anything

Thnx

Stanley
 
S

SDecou

I am stuck trying to do the same thing that you are trying to do. Did you
happen to figure it out? If not, what was your workaround to solve this
problem?
 
S

S.Y.M. Wong-A-Ton

The Command property on the QueryAdapter object cannot be used to read output
parameters returned by a stored procedure. You need to create the Command
object that comes with either ADO (script) or ADO.NET (managed code), fill
the Parameters collection of this Command object with input parameters,
output parameters, or both, for the stored procedure, and then execute the
Command object. The Command object will then fill the output parameters in
its Parameters collection with values. You can then retrieve these values.

See http://support.microsoft.com/?kbid=185125

I got this to work for both ADO and ADO.NET.
---
S.Y.M. Wong-A-Ton


SDecou said:
I am stuck trying to do the same thing that you are trying to do. Did you
happen to figure it out? If not, what was your workaround to solve this
problem?

Stanley said:
Hi,

i am executing an insert stored procedure. This stored procedure returns the
newly created identity value:
id Name
--------------
1 test2
2 test2

If i insert test3 an id with number 3 is created and returned by the stored
procedure. How can i read this value (id 3)?

This is my code for executing de SP:

ADOAdapterObject adapt =
(ADOAdapterObject)thisXDocument.DataObjects["Test"].QueryAdapter;
adapt.Command.ToString();
adapt.Command = "execute TestInsert 0,'test','MyName','01/12/2005'";
adapt.Query();

The adapt.Query() returns void, so it doesn't return anything

Thnx

Stanley
 
S

Stanley

I just created the record. After that i did a select on the table with a
filter on the "unique" fields and that way i retrieve the newly created id.
It works for me.

SDecou said:
I am stuck trying to do the same thing that you are trying to do. Did you
happen to figure it out? If not, what was your workaround to solve this
problem?

Stanley said:
Hi,

i am executing an insert stored procedure. This stored procedure returns the
newly created identity value:
id Name
--------------
1 test2
2 test2

If i insert test3 an id with number 3 is created and returned by the stored
procedure. How can i read this value (id 3)?

This is my code for executing de SP:

ADOAdapterObject adapt =
(ADOAdapterObject)thisXDocument.DataObjects["Test"].QueryAdapter;
adapt.Command.ToString();
adapt.Command = "execute TestInsert 0,'test','MyName','01/12/2005'";
adapt.Query();

The adapt.Query() returns void, so it doesn't return anything

Thnx

Stanley
 
S

Stanley

I didn't use ADO because of the security errors of IE. So i just used the IP
data connections to avoid those problems. All code is written in IP, i did
not use a web service. Probable ADO would have worked than.

S.Y.M. Wong-A-Ton said:
The Command property on the QueryAdapter object cannot be used to read output
parameters returned by a stored procedure. You need to create the Command
object that comes with either ADO (script) or ADO.NET (managed code), fill
the Parameters collection of this Command object with input parameters,
output parameters, or both, for the stored procedure, and then execute the
Command object. The Command object will then fill the output parameters in
its Parameters collection with values. You can then retrieve these values.

See http://support.microsoft.com/?kbid=185125

I got this to work for both ADO and ADO.NET.
---
S.Y.M. Wong-A-Ton


SDecou said:
I am stuck trying to do the same thing that you are trying to do. Did you
happen to figure it out? If not, what was your workaround to solve this
problem?

Stanley said:
Hi,

i am executing an insert stored procedure. This stored procedure returns the
newly created identity value:
id Name
--------------
1 test2
2 test2

If i insert test3 an id with number 3 is created and returned by the stored
procedure. How can i read this value (id 3)?

This is my code for executing de SP:

ADOAdapterObject adapt =
(ADOAdapterObject)thisXDocument.DataObjects["Test"].QueryAdapter;
adapt.Command.ToString();
adapt.Command = "execute TestInsert 0,'test','MyName','01/12/2005'";
adapt.Query();

The adapt.Query() returns void, so it doesn't return anything

Thnx

Stanley
 
S

S.Y.M. Wong-A-Ton

Your solution sounds like a good workaround.
---
S.Y.M. Wong-A-Ton


Stanley said:
I didn't use ADO because of the security errors of IE. So i just used the IP
data connections to avoid those problems. All code is written in IP, i did
not use a web service. Probable ADO would have worked than.

S.Y.M. Wong-A-Ton said:
The Command property on the QueryAdapter object cannot be used to read output
parameters returned by a stored procedure. You need to create the Command
object that comes with either ADO (script) or ADO.NET (managed code), fill
the Parameters collection of this Command object with input parameters,
output parameters, or both, for the stored procedure, and then execute the
Command object. The Command object will then fill the output parameters in
its Parameters collection with values. You can then retrieve these values.

See http://support.microsoft.com/?kbid=185125

I got this to work for both ADO and ADO.NET.
---
S.Y.M. Wong-A-Ton


SDecou said:
I am stuck trying to do the same thing that you are trying to do. Did you
happen to figure it out? If not, what was your workaround to solve this
problem?

:

Hi,

i am executing an insert stored procedure. This stored procedure returns the
newly created identity value:
id Name
--------------
1 test2
2 test2

If i insert test3 an id with number 3 is created and returned by the stored
procedure. How can i read this value (id 3)?

This is my code for executing de SP:

ADOAdapterObject adapt =
(ADOAdapterObject)thisXDocument.DataObjects["Test"].QueryAdapter;
adapt.Command.ToString();
adapt.Command = "execute TestInsert 0,'test','MyName','01/12/2005'";
adapt.Query();

The adapt.Query() returns void, so it doesn't return anything

Thnx

Stanley
 
S

SDecou

Stanley,

Could you please post a code sample of what you did? I am really lost on
what I need to do. What is IP

Stanley said:
I just created the record. After that i did a select on the table with a
filter on the "unique" fields and that way i retrieve the newly created id.
It works for me.

SDecou said:
I am stuck trying to do the same thing that you are trying to do. Did you
happen to figure it out? If not, what was your workaround to solve this
problem?

Stanley said:
Hi,

i am executing an insert stored procedure. This stored procedure returns the
newly created identity value:
id Name
--------------
1 test2
2 test2

If i insert test3 an id with number 3 is created and returned by the stored
procedure. How can i read this value (id 3)?

This is my code for executing de SP:

ADOAdapterObject adapt =
(ADOAdapterObject)thisXDocument.DataObjects["Test"].QueryAdapter;
adapt.Command.ToString();
adapt.Command = "execute TestInsert 0,'test','MyName','01/12/2005'";
adapt.Query();

The adapt.Query() returns void, so it doesn't return anything

Thnx

Stanley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top