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
|
Dim cmd As SqlCommand
Dim cnx As SqlConnection
Dim nomAdmin As Integer
cmd = New SqlCommand()
cnx = New SqlConnection()
cnx.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\3I\VB\gestionRecette2\WindowsApplication1\WindowsApplication1\Database1.mdf;Integrated Security=True;User Instance=True"
cmd.Connection = cnx
'ouverture bdd
If (cnx.State = ConnectionState.Closed) Then
cnx.Open()
End If
cmd.CommandText = "SELECT idAdmin FROM Administrateur"
nomAdmin = cmd.ExecuteScalar
MessageBox.Show(nomAdmin)
cmd.CommandText = "INSERT INTO recette (nom,difficulte,tCuisson,tPrepa,tReposJ,tReposH,tReposM,nombrePersonne,instruction,remarque,idUtilisateur,typePlat) VALUES ('" + TextBox4.Text + "','" + CType(ComboBox1.Text, Integer) + "','" + CType(TextBox1.Text, Integer) + "','" + CType(TextBox2.Text, Integer) + "','" + CType(TextBox5.Text, Integer) + "','" + CType(TextBox6.Text, Integer) + "','" + CType(TextBox7.Text, Integer) + "','" + CType(TextBox3.Text, Integer) + "','" + RichTextBox2.Text + "','" + RichTextBox1.Text + "','" + CType(nomAdmin, Integer) + "','" + ComboBox2.Text + "')"
cmd.ExecuteScalar()
'fermeture bdd
If (cnx.State = ConnectionState.Open) Then
cnx.Close()
End If |
Partager