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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%
Dim nom = Request.Form("nom")
Dim prenom = Request.Form("prenom")
Dim adresse = Request.Form("adresse")
Dim cp = Request.Form("cp")
Dim ville = Request.Form("ville")
Dim tel = Request.Form("tel")
Dim email = Request.Form("email")
Dim chiot = Request.Form("chiot")
Dim datechiot = Request.Form("datechiot")
Dim chaton = Request.Form("chaton")
Dim datechaton = Request.Form("datechaton")
Dim codebarre = Request.Form("cb")
Dim optin = Request.Form("optin")
Dim pointeur = 0
Dim isMail = ""
'Déclaration de l'objet de connexion
Dim oConnection As New System.Data.SqlClient.SqlConnection
' Ecriture de la chaîne de connexion
Dim sConnectionString As String
sConnectionString = "Server=xxx.xxx.xxx.xxx;Initial Catalog=xxx;uid=xxx;password=xxx"
oConnection.ConnectionString = sConnectionString
'requete sql
Dim sql As String
sql = "SELECT nom FROM participants WHERE email="
sql &= "'" & email & "'"
' Ouverture de la connexion
oConnection.Open()
' Traitement des opération à effectuer sur la base de données
' Cration de l'objet SqlCommand
Dim oCommand As SqlCommand
oCommand = New SqlCommand(sql, oConnection)
' Lecture des donnes
Dim odatareader As SqlDataReader
odatareader = oCommand.ExecuteReader()
Do While odatareader.Read()
isMail = odatareader(0)
Loop
' Fermeture de la connexion
'oConnection.Close()
' Fermeture du DataReader et de la connexion
odatareader.Close()
oConnection.Close()
If isMail <> "" Then ' SI LE MAIL EXISTE ON MET LE POINTEUR A 1
pointeur = 1
Else ' LE MAIL N'EXISTE PAS ON LE CREE DANS LA BDD
Dim dateinscription = DateTime.Now
Dim sql2 As String
sql2 = "INSERT INTO particpants (nom,prenom,adresse,cp,ville,tel,email,chiot,datechiot,chaton,datechaton,codebarre,optin,dateinscription)"
sql2 &= " VALUES ("
sql2 &= "'" & nom & "',"
sql2 &= "'" & prenom & "',"
sql2 &= "'" & adresse & "',"
sql2 &= "'" & cp & "',"
sql2 &= "'" & ville & "',"
sql2 &= "'" & tel & "',"
sql2 &= "'" & email & "',"
sql2 &= "'" & chiot & "',"
sql2 &= "'" & datechiot & "',"
sql2 &= "'" & chaton & "',"
sql2 &= "'" & datechaton & "',"
sql2 &= "'" & codebarre & "',"
sql2 &= "'" & optin & "',"
sql2 &= "'" & dateinscription & "')"
'Déclaration de l'objet de connexion une seconde fois?!
'Je n'arrive pas à réutiliser ma connexion précédente
Dim oConnection2 As New System.Data.SqlClient.SqlConnection
' Ecriture de la chaîne de connexion
Dim sConnectionString2 As String
sConnectionString2 = "Server=xxxx;Initial Catalog=xxx;uid=xxxx;password=xxxx"
oConnection2.ConnectionString = sConnectionString
' Ouverture de la connexion
oConnection2.Open()
' Cration de l'objet SqlCommand
Dim oCommand2 As SqlCommand
oCommand2 = New SqlCommand(sql2, oConnection2)
oCommand2.ExecuteNonQuery()
oConnection2.Close()
pointeur = 0
End If
%> |
Partager