<asp:sqldatasource ConnectionString="<%$ ConnectionStrings:Portal %>"
SelectCommand="GetPortals" ID="ds" runat="server">
<SelectParameters>
<asp:Parameter Direction="Output" Type="Int32" Name="Output" />
</SelectParameters>
</asp:sqldatasource>
and in codebehind
void Page_Load(){
ds.Selected +=new SqlDataSourceStatusEventHandler(ds_Selected);
}
void ds_Selected(object sender, SqlDataSourceStatusEventArgs e) {
}
at which point you can access e.Command.Parameters
["@Output"].SqlValue.Value or something similar.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jeff V" <Jeff V...@discussions.microsoft.com> wrote in message
news:5A784C94-CA23-4CDA...@microsoft.com...
> Hello,
>
> I am trying to call a insert proc using the SQLDatasource Control. I was
> able to call the insert just fine, but when I added an output param, I got
> lost in how to retrieve that value. The proc is working fine, but does
> anyone know how to get this value in .aspx (2.0)?
>
> Please let me know.
>
> Jeff V
>
Thanks for your reply. I'm not sure how this exactly works to get my
return value from an insert statement using the selected event. Can
you explain that further?
Basically, I want to insert a row and then return the @@identity for
that row. Which would then be used for another procedure. I know I
can do it by using ADO.net. I'm trying to figure out the
SQLDataSource in ASP.net 2.0
Thanks,
Jeff V
"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:<#Bph$oClEH...@tk2msftngp13.phx.gbl>...
<asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:Test%>" ID="sql"
Runat="server" SelectCommand="SELECT * FROM Organization"
InsertCommand="AddOrganization">
<insertparameters>
<asp:Parameter Name="Identity" Direction="ReturnValue" />
</insertparameters>
</asp:SqlDataSource>
now the Sproc AddOrganization that I'm using to insert does a RETURN
@@IDENTITY at the end....
In my code file, I can then access this value via:
private void Page_Load(object source, EventArgs e) {
sql.Inserted += new SqlDataSourceStatusEventHandler(sql_Inserted);
//hook up the Inserted event
}
void sql_Inserted(object sender, SqlDataSourceStatusEventArgs e) {
int identity =
Convert.ToInt32(((SqlParameter)e.Command.Parameters["@Identity"]).Value));
}
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jeff V" <jeff.v...@gmail.com> wrote in message
news:e9ee071.0409...@posting.google.com...