1
大家好我已創建了一個AJAX文件上傳,但它僅導入的第一張照片到我的數據庫u能幫助解決這個問題,請與Response.Redirect的是不是工作壓力太大Ajaxfileupload上傳只有一張圖片
Dim sellerid1 As Integer
Using con1 As New SqlConnection(_start)
Dim conss1 As New SqlConnection(_start)
Dim sql2 As String = "SELECT SellerID FROM Seller INNER JOIN Member ON Seller.MemberID = Member.MemberID WHERE(Member.Username = @username)"
Dim mycommand As New SqlCommand(sql2, conss1)
conss1.Open()
mycommand.Parameters.AddWithValue("@username", Session("user"))
sellerid1 = Convert.ToInt32(mycommand.ExecuteScalar)
End Using
Dim filename As String = e.FileName
Dim strDestPath As String = Server.MapPath("~/Seller/images/")
AjaxFileUpload1.SaveAs(strDestPath & filename)
Dim Imagepath As String = "~/Seller/images/" & filename
Dim conss As New SqlConnection(_start)
conss.Open()
Dim sql1 As String = "SELECT TOP (1) ItemID FROM Item WHERE (SellerID = @sellerid) ORDER BY ItemID DESC"
Dim mycommand2 As New SqlCommand(sql1, conss)
mycommand2.Parameters.AddWithValue("@sellerid", sellerid1)
ItemID = mycommand2.ExecuteScalar
Dim sql As String = "INSERT INTO Image(Image,ItemID) VALUES (@image,@item)"
Dim myCommand1 = New SqlCommand(sql, conss)
myCommand1.Parameters.AddWithValue("@image", Imagepath)
myCommand1.Parameters.AddWithValue("@item", ItemID)
myCommand1.ExecuteNonQuery()
Response.Redirect("Views/Default2.aspx")
對不起,我做我的問題一個錯誤,它僅導入一張圖片,第一個並感謝答覆的答覆。重定向 – user3371452
@ user3371452使用Uploadcomplete將所有圖片 –