Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Data
Imports System.IO
Imports System.Net
Imports System.Web.Script.Serialization
Partial Class Seller_Picture
Inherits System.Web.UI.Page
Private ReadOnly _start As String
Dim temps As Integer
Public Sub New()
_start = WebConfigurationManager.ConnectionStrings("VirgoPlaza").ConnectionString
End Sub
Dim ItemID As Integer
Protected Sub AjaxFileUpload1_UploadComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AjaxFileUploadEventArgs) Handles AjaxFileUpload1.UploadComplete
' Getting the File Name
Dim filename As String = e.FileName
' Setting the path to upload Images
AjaxFileUpload1.SaveAs(Server.MapPath("images/") & filename)
' Storing the relative path to store into images
Dim Imagepath As String = "~/images/" & filename
Using conss As New SqlConnection(_start)
conss.Open()
Dim sql2 As String = "Select AuctionID from Auction INNER JOIN Item ON Auction.ItemID = Item.ItemID Where Item.Name=@name "
Dim myCommand12 = New SqlCommand(sql2, conss)
myCommand12.Parameters.AddWithValue("@name", dbItem.SelectedItem.Text)
myCommand12.CommandType = CommandType.Text
Dim auctionid As Integer = Convert.ToInt32(myCommand12.ExecuteScalar)
Dim sql1 As String = "INSERT INTO Images (Image,AuctionID) VALUES (@image,@Auction)"
Dim myCommand1 = New SqlCommand(sql1, conss)
myCommand1.Parameters.AddWithValue("@image", Imagepath)
myCommand1.Parameters.AddWithValue("@Auction", auctionid)
myCommand1.ExecuteNonQuery()
Dim sql3 As String = "UPDATE Item SET Status =@stat FROM Item INNER JOIN Auction ON Item.ItemID = Auction.ItemID Where Auction.Auction = @auction"
Dim mycomand = New SqlCommand(sql3, conss)
mycomand.Parameters.AddWithValue("@auction", auctionid)
mycomand.Parameters.AddWithValue("@stat", "Auctionned")
mycomand.ExecuteNonQuery()
Dim sql4 As String = "Update Auction Set Status =@status where AuctionID =@auction"
Dim mycommand = New SqlCommand(sql4, conss)
Dim status As String = "Not Valid"
mycommand.Parameters.AddWithValue("@status", status)
mycommand.Parameters.AddWithValue("@auction", auctionid)
mycommand.ExecuteNonQuery()
End Using
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Using con1 As New SqlConnection(_start)
Dim sql1 As String = "SELECT Item.ItemID, Item.Name FROM Item INNER JOIN Auction ON Item.ItemID = Auction.ItemID INNER JOIN Seller ON Item.SellerID = Seller.SellerID INNER JOIN Member ON Seller.MemberID = Member.MemberID WHERE(Member.Username = @username) AND (Item.Status = 'Photo')"
con1.Open()
Dim myCommand1 As New SqlCommand(sql1, con1)
myCommand1.Parameters.AddWithValue("@username", Session("user"))
myCommand1.CommandType = CommandType.Text
Dim item As SqlDataReader
item = myCommand1.ExecuteReader()
myCommand1.Parameters.AddWithValue("@username", item)
dbItem.DataSource = item
dbItem.DataBind()
con1.Close()
End Using
End If
End Sub
End ClassCan anyone help i don't why but my ajax fileupload don't excute my command