ManuAntibes
Messages postés491Date d'inscriptionmardi 24 octobre 2000StatutMembreDernière intervention18 novembre 2021
-
13 avril 2006 à 12:25
cs_Yopyop
Messages postés586Date d'inscriptionlundi 7 janvier 2002StatutMembreDernière intervention10 février 2010
-
16 avril 2006 à 16:39
>Salut à tous
>
>Je me permet d'ecrie car je bloc sur du code.
>
>Je souhaite recup l'id de mon INSERT dans une session.
>
>Voici mon code :
>
>
> Private Sub dgclient_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgClient.ItemCommand
>
> Dim sClient As Int32 = ddlPrenom.SelectedItem.Value
> Dim sMagasin As Int32 = Int32.Parse(CType(e.Item.FindControl("dpMagasin"), DropDownList).SelectedValue)
> Dim sDateEntrant As Date = Date.Now
> Dim sDateSortant As Date = CType(e.Item.FindControl("CaldSortant"), Calendar).SelectedDate
>
> Dim sPreparer As String = "0"
> Dim sSortie As String = "0"
> Dim sAnnuler As String = "0"
> Dim Identity As Int32
> Dim sSQL As String = "INSERT INTO ListeCommandeClient(IdClient_LCC, IdMagasin_LCC, DateEntrant_LCC, DateSortant_LCC,Preparer_LCC, Sortie_LCC, Annuler_LCC) values (@Client, @Magasin, @DateEntrant, @DateSortant, @Preparer, @Sortie, @Annuler)SELECT @@IDENTITY AS 'Identity'"
>
> Dim oCon As New Data.SqlClient.SqlConnection(ConnString)
> Dim oComm As New Data.SqlClient.SqlCommand(sSQL, oCon)
> oComm.CommandType = Data.CommandType.Text
>
> oComm.Parameters.Add("@Client", Data.SqlDbType.Int).Value = sClient
> oComm.Parameters.Add("@Magasin", Data.SqlDbType.Int).Value = sMagasin
> oComm.Parameters.Add("@DateEntrant", Data.SqlDbType.DateTime).Value = sDateEntrant
> oComm.Parameters.Add("@DateSortant", Data.SqlDbType.DateTime).Value = sDateSortant
>
> oComm.Parameters.Add("@Preparer", Data.SqlDbType.NVarChar).Value = sPreparer
> oComm.Parameters.Add("@Sortie", Data.SqlDbType.NVarChar).Value = sSortie
> oComm.Parameters.Add("@Annuler", Data.SqlDbType.NVarChar).Value = sAnnuler
>
>
> oCon.Open()
> oComm.ExecuteNonQuery()
> oComm.Dispose()
>
>
> oCon.Close()
>
> Session("ID_Commande") = Identity
> Server.Transfer("CommandeClient_Ajouter1.aspx?ID_Commande")
>
> End Sub
>
>Merci de me donné un coup de main, car mon Identity est vide
>
>Cordialement
>ManuAntibes