1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Imports System.Data.SqlClient
Partial Class JeuxVideo_Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
' Déclaration de l'objet de connexion
Dim oConnection As SqlConnection
Dim strRequete As String = "INSERT into TestJeuxVideo (id,texte,) Values(" & TextBox1.Text & "," & TextBox1.Text & ")"
' Création de l'objet de connexion
oConnection = New SqlConnection
' Ecriture de la chaîne de connexion
Dim sConnectionString As String = "Server=SQL2005.HEBERGEMENT.COM;Initial Catalog=db_worldgam3_1;uid=db_worldgam3_1;password=********"
oConnection.ConnectionString = sConnectionString
' Ouverture de la connexion
oConnection.Open()
Dim oCommand As New System.Data.SqlClient.SqlCommand(strRequete, oConnection)
' Traitement des opération à effectuer sur la base de données
oCommand.ExecuteNonQuery()
' Fermeture de la connexion
oConnection.Close()
End Sub
End Class |