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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
| <% @Language=VBSCRIPT %>
<% Option Explicit %>
<!--#include file = "ConnexionBaseDeDonnees.asp"-->
<HTML>
<%If Request("autretable")="Yes" Then%>
<BODY BgColor="#CCCCFF" Text="#0033FF" Link="#00A0FF" VLink="#00C0FF">
<FONT Face="Verdana" Size="4">
<FORM METHOD=POST ACTION="EntreesFormulaire2.asp">
Nom de la table :
<INPUT TYPE=TEXT NAME=nomtable size="20">
<P>
<INPUT TYPE=HIDDEN NAME=idapplication VALUE=<%=Cint(Request("idapplication"))%>>
<INPUT TYPE=SUBMIT VALUE="Valider">
</FORM>
</FONT>
</BODY>
<%Else
'---Définition des constantes---'
Const adCmdTable = 2
Const adLockOptimistic = 3
'---Définition des variables---'
Dim objRS
Dim objRS2
Dim strSql
Dim strSql2
Dim iCurseur
Dim iIndex
Dim iIndex2
Dim iNbLignes
Dim iNbLignes2
Dim arrTables
Dim arrChamps
Dim arrTypeChamps
iIndex2 = 0
iIndex = 0
'---Creation de deux instances d'objet Recordset---'
Set objRS = Server.CreateObject("ADODB.Recordset")
Set objRS2 = Server.CreateObject("ADODB.Recordset")
'---Creation de deux requetes sql---'
strSql = "select fIdTable, tNomTable from tblCreationTable where fIdApplication = " & Cint(Request("idapplication"))
objRS.Open strSql, objConn, adLockOptimistic, adCmdTable
strSql2 = "select count(*) from tblCreationTable where fIdApplication = " & Cint(Request("idapplication"))
objRS2.Open strSql2, objConn, adLockOptimistic, adCmdTable
If objRS2(0) <> "" Then
iNbLignes = Cint(objRS2(0))-1
Redim arrTables(iNbLignes)
objRS.MoveFirst
Dim strSql3
Dim objRS3
Dim strSql4
Dim objRS4
Dim strIdTable
Dim strSql5
Dim objConn2
While not objRS.EOF
strIdTable = objRS.Fields("fIdTable").Value
arrTables(iIndex) = objRS.Fields("tNomTable").Value
Set objRS3 = Server.CreateObject("ADODB.Recordset")
Set objRS4 = Server.CreateObject("ADODB.Recordset")
'---Creation de deux requetes sql---'
strSql3 = "select tNomChamps, tTypeChamps from tblCreationChamps where fIdTable = " & strIdTable
objRS3.Open strSql3, objConn, adLockOptimistic, adCmdTable
strSql4 = "select count(*) from tblCreationChamps where fIdTable = " & strIdTable
objRS4.Open strSql4, objConn, adLockOptimistic, adCmdTable
If objRS4(0) <> "" Then
iNbLignes2 = Cint(objRS4(0))-1
Redim arrChamps(iNbLignes2)
Redim arrTypeChamps(iNbLignes2)
objRS3.MoveFirst
iIndex2 = 0
While not objRS3.EOF
arrChamps(iIndex2) = objRS3.Fields("tNomChamps").Value
arrTypeChamps(iIndex2) = objRS3.Fields("tTypeChamps").Value
objRS3.MoveNext
iIndex2 = iIndex2 + 1
Wend
Set objConn2 = Server.CreateObject("ADODB.Connection")
objConn2.Open "base_generique"
Select Case arrTypeChamps(0)
Case "Texte", "Lien hypertexte"
strSql5 = "create table " & arrTables(iIndex) & " (" & arrChamps(0) & " text Primary Key"
Case "Numerique"
strSql5 = "create table " & arrTables(iIndex) & " (" & arrChamps(0) & " numeric Primary Key"
Case "Date/Heure"
strSql5 = "create table " & arrTables(iIndex) & " (" & arrChamps(0) & " datetime Primary Key"
Case "Oui/Non"
strSql5 = "create table " & arrTables(iIndex) & " (" & arrChamps(0) & " bit Primary Key"
End Select
iCurseur = 1
While iCurseur < iIndex2
Select Case arrTypeChamps(iCurseur)
Case "Texte", "Lien hypertexte"
strSql5 = strSql5 & ", " & arrChamps(iCurseur) & " text"
Case "Numerique"
strSql5 = strSql5 & ", " & arrChamps(iCurseur) & " numeric"
Case "Date/Heure"
strSql5 = strSql5 & ", " & arrChamps(iCurseur) & " datetime"
Case "Oui/Non"
strSql5 = strSql5 & ", " & arrChamps(iCurseur) & " bit"
End Select
iCurseur = iCurseur + 1
Wend
strSql5 = strSql5 & ")"
objConn2.Execute strSql5
End If
objRS.MoveNext
iIndex = iIndex + 1
objRS3.Close
Set objRS3 = Nothing
objRS4.Close
Set objRS4 = Nothing
objConn.Close
Set objConn = Nothing
Wend
End If
'---Elimination des objets ADO---'
objRS.Close
Set objRS = Nothing
objRS2.Close
Set objRS2 = Nothing
End If
objConn.Close
Set objConn = Nothing
%>
</HTML> |
Partager