Treedent
Messages postés2Date d'inscriptionmercredi 25 février 2004StatutMembreDernière intervention12 janvier 2009
-
12 janv. 2009 à 12:40
kallabi
Messages postés1Date d'inscriptionsamedi 18 juillet 2009StatutMembreDernière intervention28 août 2009
-
28 août 2009 à 15:52
Quelque chose de si simple à faire en PHP, mais en VB.net c'est une autre affaire.
Je réalise grace à un TableAdapter une insertion de commande :
Dim insertCommande = Me.CommandesTableAdapter.InsertCommandeQuery(Me.ComboFournisseurs.SelectedValue, Me.ComboDateTimeCmd.Value)
La requête dans mon table adapter est simple :
INSERT INTO Commandes (idFournisseur, date) VALUES (@idFournisseur,@date);
Dans ma table j'ai un champ "Ident" auto-incrémenté qui voit sa valeur créée automatiquement. Jusqu' ici ok, tout fonctionne bien.
Mais comment récupérer l'id de cette insertion ?
Une nouvelle requête dans mon Table Adapter :
SELECT Ident AS LastInsertID FROM Commandes WHERE (Ident = @@IDENTITY)
ou encore
Select @@IDENTITY AS LastInsertID
Ne renvoient rien !
Nota : "Select @@IDENTITY AS Expr1" à la suite de l'insert dans la même requete du TableAdapter renvoie des Erreurs SQL (Limitation SQL Compact ?????)
Comment stocker dans une variable VB de type Integer ce pu..... d'id ?
kallabi
Messages postés1Date d'inscriptionsamedi 18 juillet 2009StatutMembreDernière intervention28 août 2009 28 août 2009 à 15:52
// Private Sub aff_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles aff.SelectedIndexChanged
If (aff.Text <> "") Then
Rsql = "select des_evn,dat_evn,int_pup,int_chef,nom_ouv from evenement,solution,elaboration,equipe where evenement.cod_evn=elaboration.cod_evn and equipe.num_ouv=elaboration.num_ouv and evenement.cod_evn= evensol and solution.num_sol=evensol.num_sol groupby des_evn,dat_evn,int_pup,int_chef,nom_ouv and evenement.typ_evn='" & aff.Text & "' "
Cmdafftype.CommandType = CommandType.Text
Cmdafftype.CommandText = Rsql
End If
Try
DAdapter.Fill(DSevenements, "evenements")
Dataaff.DataSource = DSevenements.Tables("evenements")
Catch ex As Exception
MsgBox(ex.Message)
End Try//
POUR REMLPIR DATAGRID
MAIS MESSAGE TOUJOURS AFFICHER//Fill:la propriete SelectCommand .la connection n'a pas ete initialisée
y-a-il une solution