---
title: "Hjälp med översättning till MySQL"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/117095-hjälp-med-översättning-till-mysql"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "airwolf"
published: "2004-12-01T12:38:39.000Z"
updated: "2004-12-02T09:55:22.000Z"
replies: 2
views: 248
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/117095-hjälp-med-översättning-till-mysql"
---

# Hjälp med översättning till MySQL

## #1 — airwolf, 2004-12-01T12:38Z

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

Permalänk: https://www.webforum.nu/p/117095

## #2 — airwolf, 2004-12-01T14:09Z

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 
%>
```

Permalänk: https://www.webforum.nu/p/1497982

## #3 — airwolf, 2004-12-02T09:55Z

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,

Permalänk: https://www.webforum.nu/p/1498394

---

Tråden på webben: https://www.webforum.nu/amne/asp/117095-hjälp-med-översättning-till-mysql
