Database 上载文件时从数据库中删除的记录

Database 上载文件时从数据库中删除的记录,database,file-upload,image,Database,File Upload,Image,当我尝试将多张图片上传到数据库时,我的代码工作正常,所有图片都显示在库中,但当我尝试修改数据库中的图片,并修改一张图片时,它会从数据库中删除其余图片。记录集没有被删除,其余的信息保持不变,只是我为那些数据被删除的图片保留了5个以上的位置。这是我到目前为止的代码 message.Text = "please wait" pics.Visible = False 'wherepics are stored Dim savepath As String = Server.Map

当我尝试将多张图片上传到数据库时,我的代码工作正常,所有图片都显示在库中,但当我尝试修改数据库中的图片,并修改一张图片时,它会从数据库中删除其余图片。记录集没有被删除,其余的信息保持不变,只是我为那些数据被删除的图片保留了5个以上的位置。这是我到目前为止的代码

message.Text = "please wait"
    pics.Visible = False
    'wherepics are stored
    Dim savepath As String = Server.MapPath("/cgi-bin/properties/")
    Dim tfn0 As String = ""
    Dim tfn1 As String = ""
    'dims the filenames a variables
    Dim img0 As String = pic0.FileName
    Dim img1 As String = pic1.FileName
    'this is the set of paths to check
    'this will check for redundencies in the database so no dublicate file names will occur
    Dim ptc0 As String = savepath + img0
    Dim ptc1 As String = savepath + img1

    Dim url0 As String = ""
    Dim url1 As String = ""
    Dim counter As Integer = 2
    If (System.IO.File.Exists(ptc0)) Then
        While (System.IO.File.Exists(ptc0))
            tfn0 = counter.ToString = img0
            ptc0 = savepath + tfn0
            counter = counter + 1
        End While
    ElseIf (System.IO.File.Exists(ptc1)) Then
        While (System.IO.File.Exists(ptc1))
            tfn1 = counter.ToString = img1
            ptc1 = savepath + tfn1
            counter = counter + 1
        End While
    End If
    Dim sp0 As String = savepath + img0
    Dim sp1 As String = savepath + img1
    If Not pic0.FileName = Nothing Then
        pic0.SaveAs(sp0)
        img0 = pic0.FileName
        url0 += "pic_main"
        url1 += img0
    End If
    If Not pic1.FileName = Nothing Then
        If pic0.FileName = Nothing Then
            pic1.SaveAs(sp1)
            img1 = pic0.FileName
            url0 += "pic_one"
            url1 += img1
        Else
            pic1.SaveAs(sp1)
            img1 = pic0.FileName
            url0 += ", pic_one"
            url1 += ", " & img1
        End If

    End If

    Dim datanames() As String = {url0}
    ', "pic_six", "pic_seven", "pic_eight", "pic_nine"
    Dim datavalues() As String = {url1}
    ', file6, file7, file8, file9
    DB.UpdateCommand(datanames, datavalues, "property", "property_id = " & Request.QueryString("id")) ', true)
    Response.Redirect("finished.aspx")

我已经找到了解决方案,它正在查看所有的文件上传控件,因为它们中没有任何内容,它将引用那些我刚才发现的字段,这些字段很忙,没有时间发布我的答案。在数据库中,删除其中的任何内容,并将其替换为空白。我对代码做了一点修改,让用户选择他们想要更新的插槽,然后执行一个qstring,而不是让它一次更新所有的qstring

我找到了解决方案,它正在查看所有的文件上载控件,因为其中没有任何内容,它会引用我刚才发现的字段,忙得没时间发布我的答案。在数据库中,删除其中的任何内容,并将其替换为空白。我稍微修改了代码,让用户选择要更新的插槽,然后继续执行qstring,而不是让它一次更新所有的qstring。