webForumDet fria alternativet

IF satser igen

ASPur ASP

1 svar · 228 visningar · startad av His Divine Shadow

Medlem sedan sep. 20004 079 inlägg
Frågan#1

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?

------------------
His Divine Shadow is the most despicable being ever created, short and to the point.

http://forums.planetdivine-shadow.com

Sprit löser inga problem. Men det gör inte mjölk heller.

Medlem sedan dec. 19998 577 inlägg
#2

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

------------------
Doesn't 'expecting the unexpected' make the unexpected expected?
webeye.nu

132 ms totalt · 3 externa anrop · v20260731065814-full.8a4e7caf
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
129 ms — hämta tråd, inlägg och bilagor (db)