webForumDet fria alternativet

Hjälp med översättning till MySQL

ASP

2 svar · 240 visningar · startad av airwolf

Medlem sedan okt. 2003132 inlägg
Frågan#1

Kan nån hjälpa mig att översätta nedan till MySQL
Det är en bild som ska skrivas in i ett blob fält

For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then

  '  Add the current file in a DB field
  '  \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
     oRs.AddNew
     file.FileToField oRs.Fields("image")
	 oRs("code_no") = file.FileName
     oRs.Update
     intCount = intCount + 1
  End If

Next

Medlem sedan okt. 2003132 inlägg
#2

Hela koden ser i dagsläget ut:

<%
'  Variables
'  *********
   Dim mySmartUpload
   Dim file
   Dim oConn
   Dim oRs
   Dim intCount
   intCount=0
        
'  Object creation
'  ***************
   Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

'  Upload
'  ******
   mySmartUpload.Upload

'  Connect to the DB
'  *****************
   Set oConn = Server.CreateObject("ADODB.Connection")
   curDir = Server.MapPath("\scripts\aspSmartUpload\Sample.mdb")
   oConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"

'  Open a recordset
'  ****************
   strSQL = "SELECT FILENAME,FILE FROM TFILES"

   Set oRs = Server.CreateObject("ADODB.recordset")
   Set oRs.ActiveConnection = oConn
   oRs.Source = strSQL
   oRs.LockType = 3
   oRs.Open

'  Select each file
'  ****************
   For each file In mySmartUpload.Files
   '  Only if the file exist
   '  **********************
      If not file.IsMissing Then

      '  Add the current file in a DB field
      '  **********************************
         oRs.AddNew
         file.FileToField oRs.Fields("FILE")
		 oRs("FILENAME") = file.FileName
         oRs.Update
         intCount = intCount + 1
      End If
   Next

'  Display the number of files uploaded
'  ************************************
   Response.Write(intCount & " file(s) uploaded.<BR>")

'  Destruction
'  ***********
   oRs.Close
   oConn.Close
   Set oRs = Nothing 
   Set oConn = Nothing 
%>
Medlem sedan okt. 2003132 inlägg
#3

Så här har jag för tillfället

  strSQL = "SELECT * FROM products where code_no = '" & code_no & "'" 
  Set oRs = oConn.Execute(strSQL)

'  Select each file
'  ****************
   For each file In mySmartUpload.Files
   
   '  Only if the file exist
   '  **********************
 If not file.IsMissing Then

      '  Add the current file in a DB field
      '  **********************************
        file.FileToField oRs.Fields("image")
        strInsert = "INSERT INTO products (imagename) VALUES ('" & file.FileName & "' )"
        strInsert = "Update products Set image = '" & file.FileToField & "' where code_no = '" & code_no & "'" 
        Response.Write(strInsert)
        oConn.Execute(strInsert)
        'intCount = intCount + 1
        
        
        
      End If
   Next

Men file.FileToField oRs.Fields("image") vill inte funka, och det är den som skriver in bilden i databasen,

256 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
123 ms — deklarationer (db)
0 ms — hämta statistik (cache)
129 ms — hämta tråd, inlägg och bilagor (db)
122 ms — ändringar (db)