Imports System.Data.SqlClient
Imports System.Data
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim query As String = "SELECT DISTINCT Item.Name FROM Auction INNER JOIN Item ON Auction.ItemID = Item.ItemID WHERE(Auction.Status = 'Valid')"
Dim dt As DataTable = GetData(query)
DropDownList1.DataSource = dt
DropDownList1.DataTextField = "Name"
DropDownList1.DataValueField = "Name"
DropDownList1.DataBind()
DropDownList2.DataSource = dt
DropDownList2.DataTextField = "Name"
DropDownList2.DataValueField = "Name"
DropDownList2.DataBind()
DropDownList2.Items(1).Selected = True
End If
End Sub
Private Shared Function GetData(query As String) As DataTable
Dim dt As New DataTable()
Dim constr As String = ConfigurationManager.ConnectionStrings("VirgoPlaza").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand(query)
Using sda As New SqlDataAdapter()
cmd.CommandType = CommandType.Text
cmd.Connection = con
sda.SelectCommand = cmd
sda.Fill(dt)
End Using
End Using
Return dt
End Using
End Function
Protected Sub Compare(sender As Object, e As EventArgs)
Dim query As String = String.Format("SELECT DISTINCT DATENAME(MM, BID.Date) AS Month, COUNT(BID.BidID) AS TotalBids FROM BID INNER JOIN Auction ON BID.AuctionID = Auction.AuctionID INNER JOIN Item ON Auction.ItemID = Item.ItemID WHERE (Auction.Status = 'Valid')
and Item.Name ='{0}' GROUP BY DATENAME(mm, BID.Date)", DropDownList1.SelectedItem.Value)
Dim dt As DataTable = GetData(query)
Dim x As String() = New String(dt.Rows.Count - 1) {}
Dim y As Decimal() = New Decimal(dt.Rows.Count - 1) {}
For i As Integer = 0 To dt.Rows.Count - 1
x(i) = dt.Rows(i)(0).ToString()
y(i) = Convert.ToInt32(dt.Rows(i)(1))
Next
LineChart1.Series.Add(New AjaxControlToolkit.LineChartSeries() With { _
.Name = DropDownList1.SelectedItem.Value, _
.Data = y _
})
query = String.Format("SELECT DISTINCT DATENAME(MM, BID.Date) AS Month, COUNT(BID.BidID) AS TotalBids FROM BID INNER JOIN Auction ON BID.AuctionID = Auction.AuctionID INNER JOIN Item ON Auction.ItemID = Item.ItemID WHERE (Auction.Status = 'Valid') and Item.Name
='{0}' GROUP BY DATENAME(mm, BID.Date)", DropDownList2.SelectedItem.Value)
dt = GetData(query)
y = New Decimal(dt.Rows.Count - 1) {}
For i As Integer = 0 To dt.Rows.Count - 1
x(i) = dt.Rows(i)(0).ToString()
y(i) = Convert.ToInt32(dt.Rows(i)(1))
Next
LineChart1.Series.Add(New AjaxControlToolkit.LineChartSeries() With { _
.Name = DropDownList1.SelectedItem.Value, _
.Data = y _
})
LineChart1.CategoriesAxis = String.Join(",", x)
LineChart1.ChartTitle = String.Format("{0} and {1} Order Distribution", DropDownList1.SelectedItem.Value, DropDownList2.SelectedItem.Value)
LineChart1.Visible = True
End Sub
End Class
can please help
telling this error