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 29 30 31 32 33 34 35 36 37 38
|
Imports ADODB
Public Class acceuil
Dim Cnn_Connexion As New ADODB.Connection()
Dim Cmd_CommandeSQL As New ADODB.command()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Cnn_Connexion.Open("Provider=SQLOLEDB;server=SQLEXPRESS;UID=User;PWD=Password;database=ping;")
Cmd_CommandeSQL.ActiveConnection = Cnn_Connexion
End Sub
Private Sub cmd_creation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_creation.Click
Try
Cmd_CommandeSQL.CommandText = "create table agence" & "(ip varchar(20)primary ke," & "agence_nom varchar(30)," & "localistation varchar(30)," & "adresse_mail varchar(30));"
Cmd_CommandeSQL.Execute()
Cmd_CommandeSQL.CommandText = "create table etat" & "(id_etat int primary key," & "ip varchar(20)refrences agence," & "etat varchar(10)," & "date datetime); "
Cmd_CommandeSQL.Execute()
MsgBox("les tables ont été crées !", MsgBoxStyle.Information, "resulat")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub cmd_suppression_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_suppression.Click
On Error Resume Next
Cmd_CommandeSQL.CommandText = "drop agence"
Cmd_CommandeSQL.execute()
Cmd_CommandeSQL.commandText = "drop table etat"
Cmd_commandeSQL.execute()
End Sub
Private Sub Form1_closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.closing
Cnn_Connexion.Close()
End Sub
End Class |
Partager