Dr Lous I see old password | Code :
- <%@Language="VBScript" %>
- <%
- Application("Root" ) = "C:\inetpub\wwwroot\"
-
- DIM size
- size = Request.TotalBytes
- Response.Write size & " octets envoyés<BR>"
- IF size > 0 THEN
- '-----------------------------------------------------------
- '-Transformation des données à sauvegarder------------------
- '-En effet les fonctions VbScript travaillent en Unicode----
- '-Le flot de caractères de la requête HTTP est en ASCII-----
- '-----------------------------------------------------------
- temp = Request.BinaryRead(size)
- theRequestString = ""
- Response.Write "<PRE Style=""background: #E0E0E0"">"
- FOR i = LBound(temp)+1 to UBound(temp)-1
- myChar = Chr(AscB(MidB(temp,i+1,1)))
- Response.write myChar
- theRequestString = theRequestString & myChar
- NEXT
- Response.Write "</PRE>"
- '-----------------------------------------------------------
- '-Récupération du nom du fichier----------------------------
- '-----------------------------------------------------------
- pos = InStr(1, theRequestString, "filename=", 0) + 10
- begin = pos
- DO ' Il faut supprimer tout ce qui préfixe le nom du fichier
- theChar = Mid(theRequestString,pos,1)
- IF theChar = """" THEN EXIT DO
- IF theChar = "/" OR theChar = "\" THEN begin = pos+1
- pos = pos + 1
- LOOP
- filename = Mid(theRequestString, begin, pos-begin)
- Response.Write "Nom du fichier à sauvegarder : " & filename
- '-----------------------------------------------------------
- '-Récupération des données à sauvegarder--------------------
- '-----------------------------------------------------------
- firstReturnPos = InStr(1,theRequestString,vbCrLf,0)
- doubleReturnPosition = InStr(firstReturnPos,theRequestString, _
- vbCrLf & vbCrLf,0)
- size = Len(theRequestString) - doubleReturnPosition - firstReturnPos - 8
- theRequestString = Mid(theRequestString, doubleReturnPosition+4, size)
- 'Response.Write "<PRE Style=""background: #E0E0E0"">" _
- ' & theRequestString & "</PRE>"
- '-----------------------------------------------------------
- '-Sauvegarde des données à sauvegarder----------------------
- '-----------------------------------------------------------
- SET fs = Server.CreateObject("Scripting.FileSystemObject" )
- SET file = fs.CreateTextFile(Application("Root" ) & filename, True)
- file.write theRequestString
- file.close
- SET file = NOTHING
- SET fs = NOTHING
- END IF
- %>
- <!--
- Le paramètre ENCTYPE est vital : c'est lui qui transmet les octets
- du fichier à copier. La méthode de postage doit être "Post".
- -->
- <FORM action="upload.asp" Method="Post" ENCTYPE="multipart/form-data">
- <INPUT Type="file" Name="file"> <BR>
- <INPUT Type="Submit" Value="Envoyer">
- </FORM>
|
(sur le net ca, car moi et l'asp.... ^^)
Code :
- <% ' Export MSAccess >> MySQL
- Set FSO = Server.CreateObject("Scripting.FileSystemObject" )
- BASE = "mabase" ' Adaptez votre chaîne de connexion !
- basePath = server.mapPath("/htdocs" ) & "\..\database\" & BASE & ".mdb"
- TABLE = "matable"
- SQL = "SELECT * FROM [" & TABLE & "]" ' par exemple
- ' nom du fichier d'export (dans rep déprotégé !!!)
- fichier = server.mapPath("/data" ) & "\" & BASE & "_" & TABLE & ".txt"
- ' Connexion à la base
- Set Conn = Server.CreateObject("ADODB.Connection" )
- Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & basePath
- ' Ouverture du recordset
- Set RS = Server.CreateObject("ADODB.Recordset" )
- RS.open SQL,conn,3,3
- ' Commentaires non lus par PhpMyAdmin
- MySQLstr = "#" & VbCrLf _
- & "# Export Access >> MySQL" & VbCrLf _
- & "# by ASP-PHP.net" & VbCrLf _
- & "#" & VbCrLf _
- & "# DB : " & BASE & VbCrLf _
- & "# SQL : " & SQL & VbCrLf _
- & "#" & VbCrLf & VbCrLf
- ' Destruction optionnelle de la table
- MySQLstr = MySQLstr & "DROP TABLE IF EXISTS `" & TABLE & "`;" & VbCrLf
- ' Création de la table
- MySQLstr = MySQLstr & "CREATE TABLE `" & TABLE & "` (" & VbCrLf
- ' Création des champs
- for each Champ in RS.fields
- temp = " `" & Champ.name & "` "
- select case Champ.type
- case 2 : ' Entier court
- MySQLstr = MySQLstr & temp & "smallint," & VbCrLf
- case 3 : ' Entier long
- MySQLstr = MySQLstr & temp & "int," & VbCrLf
- case 4 : ' Réel
- MySQLstr = MySQLstr & temp & "float," & VbCrLf
- case 5 : ' Réel long
- MySQLstr = MySQLstr & temp & "double," & VbCrLf
- case 6 : ' Monétaire
- MySQLstr = MySQLstr & temp & "float(15,4)," & VbCrLf
- case 11 : ' Booléen
- MySQLstr = MySQLstr & temp & "char(1)," & VbCrLf
- case 17 : ' Byte
- MySQLstr = MySQLstr & temp & "tinyint," & VbCrLf
- case 135 : ' Date/Time
- MySQLstr = MySQLstr & temp & "datetime," & VbCrLf
- case 200,202 : ' Texte
- MySQLstr = MySQLstr & temp & "varchar(" & Champ.definedsize & " )," & VbCrLf
- case 201,203 : ' Mémo
- MySQLstr = MySQLstr & temp & "longtext," & VbCrLf
- ' sinon non exporté...
- end select
- next
- ' Fin de la création de la table
- MySQLstr = left(MySQLstr,len(MySQLstr)-3) & VbCrLf & " ) TYPE=MyISAM;" & VbCrLf & VbCrLf
- ' Fonctions de conversion
- function n2t(n,w) ' Entier > chaine 000x ou 0x
- n2t = right("000" & cStr(n),w)
- end function
- function txt2mys(txt) ' Caractères spéciaux pour INSERT
- dim temp
- if not isnull(txt) then
- temp = replace(txt,VbCrLf,"\r\n" )
- temp = replace(temp,chr(13),"\r\n" )
- txt2mys = replace(temp,"'","\'" )
- end if
- end function
- ' Création des enregistrements
- while not RS.eof
- MySQLstr = MySQLstr & "INSERT INTO `" & TABLE & "` ("
- ' Les noms
- for each Champ in RS.fields
- select case Champ.type
- case 2,3,4,5,6,11,17,135,200,201,202,203 : MySQLstr = MySQLstr & "`" & Champ.name & "`,"
- ' sinon non exporté...
- end select
- next
- ' Les valeurs
- MySQLstr = left(MySQLstr,len(MySQLstr)-1) & " ) VALUES ("
- for each Champ in RS.fields
- select case Champ.type
- case 2,3,4,5,6,17 : ' Numériques
- MySQLstr = MySQLstr & Champ.value & ","
- case 11 : ' Booléen >> char(1) : "Y" ou "N"
- if(Champ.value) then MySQLstr = MySQLstr & "'Y'," _
- else MySQLstr = MySQLstr & "'N',"
- case 135 : ' Date time >> YYYY-MM-DD HH:MM:SS
- MySQLstr = MySQLstr & "'" _
- & n2t(year(Champ.value),4) & "-" _
- & n2t(month(Champ.value),2) & "-" _
- & n2t(day(Champ.value),2) & " " _
- & n2t(hour(Champ.value),2) & ":" _
- & n2t(minute(Champ.value),2) & ":" _
- & n2t(second(Champ.value),2) & "',"
- case 200,201,202,203 : ' Texte >> nettoyage
- MySQLstr = MySQLstr & "'" & txt2mys(Champ.value) & "',"
- ' sinon non exporté...
- end select
- next
- MySQLstr = left(MySQLstr,len(MySQLstr)-1) & " );" & VbCrLf
- ' Enregistrement suivant
- RS.movenext
- wend
- ' Fermeture de la connexion
- RS.close : conn.close
- ' Ecriture du fichier
- set inF = FSO.openTextFile(Fichier,2,true)
- inF.writeLine(MySQLstr)
- inF.close
- ' On affiche + lien vers fichier
- fichier = replace(fichier,"\","/" )
- response.write "<A target=""_blank"" href=""" & fichier & """>" & fichier & "</A><br><br>" _
- & replace(MySQLstr,VbCrLf,"<br>" )
- %>
|
et ca pour le sql
sinon ya plein de site ki peuvent t'aider a faire ce ke tu veut  ---------------
Oseras-tu m'affronter ?
|