---
title: "IF satser igen"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/12372-if-satser-igen"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "His Divine Shadow"
published: "2001-10-31T08:13:00.000Z"
updated: "2001-10-31T08:17:00.000Z"
replies: 1
views: 241
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/12372-if-satser-igen"
---

# IF satser igen

## #1 — His Divine Shadow, 2001-10-31T08:13Z

Okie, koden först:

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

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

   Set skapamapp = mySmartUpload.Form("Username")

'  Save the files with their original names in a virtual path of the web server
'  ****************************************************************************
   intCount = mySmartUpload.Save("/Katalog/Images/" & skapamapp)
   ' sample with a physical path 
   ' intCount = mySmartUpload.Save("c:\temp\")
   
'Declare all local variables
dim conn
dim rs
dim strID
dim strconn
'set a local variable to my DSN-less connection String
strconn = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\data\WebData\katalog.mdb;"

'Create the Connection object 
set conn = server.createobject("adodb.connection")
conn.open strconn

'Create the recordset object
set rs = server.createobject("adodb.recordset")

'This statement opens the table so we can add a record notice the addnew 
'The 2, 2 is how the table is opened there are many ways it can be opened
SQL = "SELECT * from Kat WHERE ID = " & mySmartUpload.Form("ID") & ""

rs.open sql, conn, 2, 2, adCmdText

'Set the table column = to my input text box from my form
rs("Filename") = mySmartUpload.Files.Item(1).FileName
rs("produktbild") = mySmartUpload.Files.Item(2).FileName
rs.update

'Always! Always set your objects to nothing.  This clears them out of servers memory
'Your network admins will like this
%>
<!--#include file="include.asp"-->
<%
set rs= nothing
set conn = nothing
%>
```

Vad jag vill ha är en if sats som gör så att om:
rs("produktbild") = mySmartUpload.Files.Item(2).FileName
rs.update

Så är tom, alltså ingenting skickades, så då ska den inte köras, går det att göra såhär kanske?

```
IF mySmartUpload.Files.Item(2).FileName = "" then
Else
rs("produktbild") = mySmartUpload.Files.Item(2).FileName
rs.update
End if
```

Skulle det kanske funka?

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

## #2 — Vide, 2001-10-31T08:17Z

Först och främst så skulle jag lägga "mySmartUpload.Files.Item(2).FileName" i en egen variabel om man skall använda den mer än en gång. :)

Och if-satsen:

```
if mySmartUpload.Files.Item(2).FileName <> "" then
rs("produktbild") = mySmartUpload.Files.Item(2).FileName
rs.update
end if
```

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/12372-if-satser-igen
