Problema:
nella parte aspx del mio webform, nell'insertcommand del mio bel sqldatasource, alla fine ho aggiunto l'istruzione in oggetto.
codice:
... InsertCommand="INSERT INTO ....; SET @lastID=SCOPE_IDENTITY()"
Non ho mancato di aggiungere tra gli insertParameters il parametro lastID con direzione Output.
codice:
<asp:Parameter Name="dd_IDcli" Type="Int32" DefaultValue="0"></asp:Parameter>
<asp:Parameter Name="lastID" Type="Int32" Direction="Output" />
Well, perchè da codebehind, nell'evento formview.iteminserted, dopo che ha effettivamente registrato il record in db, riesco a leggere il valore di tutti i parametri tranne il lastID?
codice:
Protected Sub formview_destInserted(sender As Object, e As FormViewInsertedEventArgs) Handles FormView2.ItemInserted
e.values("dd_IDcli") <- ottengo il valore inserito
e.Values("lastID") <-ottengo nothing