Bonjour tout le monde,
après avoir écumé les sites web sur comment récupérer un ID du dernier enregistrement effectué par un utilisateur précis, et après avoir trouvé la réponse, je dois matérialiser ma requête en VB.NET. voici un exemple de code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 Dim oConn As MySqlConnection Dim myCommand As New MySqlCommand Dim Cave As String 'Dim Financement As String 'Dim Stationnement As String Dim asciA As String Dim tyPecuisineus As String oConn = New MySqlConnection() oConn.ConnectionString = "server =127.0.0.1;user id=sample; password='sample';database= PMV" myCommand.Connection = oConn mycommand.commandtext = "INSERT INTO foo VALUES('"&0&"','"& text1.text &"');" Try oConn.Open() myCommand.ExecuteNonQuery() Catch myerror As MySqlException MessageBox.Show("Error Connecting to Database: " & myerror.Message) Finally oConn.Dispose() End Try End Sub
dans la ligne mycommand.commandtext puis je rajouter ceci ?:
merci pour votre retour!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 mycommand.commandtext = "INSERT INTO foo VALUES('"&0&"','"& text1.text &"');" & "INSERT INTO foo2 (foo2.fid,foo2.text) VALUES('LAST_INSERT_ID()'&",'"&text1.text&"');"
Partager