The database I am using is SQL Anywhere from Sybase. v 11.0.1
I have the following stored procedure to insert a row. I
return the @@identity variable with a select statement.
ALTER PROCEDURE "DBA"."Portal_InsertHeader"( in
theimi integer, in theUser long varchar, in
theNextServiceDate date)
RESULT( ident integer )
BEGIN
insert into
InvoiceCreditHeader(imi,createdby,nextServiceDate)
values(theimi,theUser,theNextServiceDate);
select @@identity;
END
In my ASP.NET web app I have the following in the
SQLDataSource. I am using the output type in the last
parameter.
<asp:SqlDataSource ID="sqldsHeader" runat="server"
ConnectionString="<%$ ConnectionStrings:MSPortal %>"
ProviderName="<%$
ConnectionStrings:MSPortal.ProviderName %>"
InsertCommand="Call
Portal_InsertHeader(?,?,?)"
InsertCommandType="StoredProcedure">
<InsertParameters>
<asp:Parameter Name="IMI" Type="Int32" />
<asp:Parameter Name="USER" Type="String" />
<asp:Parameter Name="NextServiceDate"
Type="DateTime" />
<asp:Parameter direction="Output"
name="HeaderID" type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:Parameter Name="ID" Type="Int32"
DefaultValue="0" />
</SelectParameters>
</asp:SqlDataSource>
When I call the .Insert method the row is inserted fine, but
when I try to check the Output parameter in the “Inserted”
method I get a null value.
So what do I need to change to get access to the output
variable in the ASP.NET code?
The solution was to use a parroter in the stored procedure with the inout keyword. Using just “out” didn’t seem to do it but all worked as expected when I changes it to “inout”