0
複数の画像をデータベースにアップロードしようとすると、コードが正常に動作し、すべての画像がギャラリーに表示されますが、データベース内の画像を修正して、残りのピクチャをデータベースから削除します。レコードセットは削除されず、残りの情報は同じままです。データが削除された画像のための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を持ち越してすべてを一度に更新するようにしました。 –