PDA

View Full Version : error of upload



sanaz_amiri
یک شنبه 29 شهریور 1383, 10:56 صبح
If Not (pdf.PostedFile Is Nothing) Then
Try

'Dim fileName As String = System.IO.Path.GetExtension(Image_.PostedFile.File Name)
Dim fileName As String = System.IO.Path.GetFileName(pdf.PostedFile.FileName )

Dim destdir As String = Server.MapPath("../nomarat")
Dim destPath As String = System.IO.Path.Combine(destdir, fileName)
label1.Text += destPath
pdf.PostedFile.SaveAs(destPath)
If fileName <> "" Then
cmd = New SqlCommand("insert into tbleraeh (nomarat) values(fileName) where eraehcode='" & var1 & "'", conn)
'cmd = New SqlCommand("insert into tbleraeh (nomarat) values(fileName) where eraehcode=100", conn)

End If

Catch
cmd = New SqlCommand("insert into tbleraeh (nomarat) values(' nofile ') where eraehcode='" & var1 & "'", conn)

Finally
End Try






error::

The name 'fileName' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted

Vahid_Nasiri
یک شنبه 29 شهریور 1383, 18:12 عصر
عبارت اس کیوال خود را به صورت زیر اصلاح کنید:


insert into tbleraeh (nomarat) values('"+fileName+"') where ...

Peyman_Ranjbar
دوشنبه 30 شهریور 1383, 04:54 صبح
عبارت اس کیوال خود را به صورت زیر اصلاح کنید:


insert into tbleraeh (nomarat) values('"+fileName+"') where ...

فکر کنم به جای + باید & بزاریم
شرمنده جسارت نباشه استاد

SoheilKH
دوشنبه 30 شهریور 1383, 16:29 عصر
فکر کنم به جای + باید & بزاریم

Operator + برای concatenate دو رشته هم می تونه استفاده بشه

Vahid_Nasiri
دوشنبه 30 شهریور 1383, 17:58 عصر
بله. در وی بی هر دو حالت صحیح است.