0

Dev Express チャート コントロールを使用することで、今日、昨日、週、月、および年ベースのクエリに基づいたチャートの一部を作成しています。しかし、問題は、このエラーが発生していることです。

データソースには、「期間」という名前のデータメンバーが含まれていません。

ここで、getDataset は過去 6 か月から使用しているグローバル関数で、完全に alright.plz ヘルプです。助けていただければ幸いです

これが私の完全な方法です

Protected Sub populateLoginHistoryChart(ByVal ddlSelectedValue As String)

    Dim sqlQuery As String = Nothing
    sqlQuery = "SELECT LT.LogOnTime AS duration , COUNT(*) AS posts "
    sqlQuery += " FROM ( "
    sqlQuery += "SELECT CASE"
    sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 0 AND DATEPART(hh,[LogOnTime]) <= 4 AND DATEPART(mm,[LogOnTime]) <= 59 then '00:00-04:00'"
    sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 4 AND DATEPART(hh,[LogOnTime]) <= 8 AND DATEPART(mm,[LogOnTime]) <= 59 then '04:00-08:00' "
    sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 8 AND DATEPART(hh,[LogOnTime]) <= 12 AND DATEPART(mm,[LogOnTime]) <= 59 then '08:00-12:00' "
    sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 12 AND DATEPART(hh,[LogOnTime]) <= 16 AND DATEPART(mm,[LogOnTime]) <= 59 then '12:00-16:00' "
    sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 16 AND DATEPART(hh,[LogOnTime]) <= 20 AND DATEPART(mm,[LogOnTime]) <= 59 then '16:00-20:00' "
    sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 20 AND DATEPART(hh,[LogOnTime]) <= 23 AND DATEPART(mm,[LogOnTime]) <= 59 then '20:00-23:00' "
    sqlQuery += " End as LogOnTime "
    sqlQuery += " FROM StudentLoginHistory"

    If ddlSelectedValue = "Today" Then
        sqlQuery += " WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, LogOnTime)) = DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))"
        sqlQuery += " )LT "
    ElseIf ddlSelectedValue = "Yesterday" Then
        sqlQuery += " WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, LogOnTime)) = DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))-1 "
        sqlQuery += " )LT "
    End If

    sqlQuery += " GROUP BY LT.LogOnTime"
    sqlQuery += " ORDER BY duration"

    If ddlSelectedValue = "Week" Then
        sqlQuery = "SELECT CONVERT(varchar(25),LogOnTime,107) AS duration, count(*) AS posts"
        sqlQuery += " FROM StudentLoginHistory WHERE "
        sqlQuery += " DateDiff(Week,LogOnTime,GetDate())=1"
        sqlQuery += " GROUP BY CONVERT(varchar(25),LogOnTime,107)"
        sqlQuery += " ORDER BY duration"

    ElseIf ddlSelectedValue = "Month" Then
        sqlQuery = "SELECT LT.LogOnTime AS duration, COUNT(*) AS posts"
        sqlQuery += " FROM (SELECT CASE "
        sqlQuery += " When DATEPART(dd,[LogOnTime]) >= 1 AND DATEPART(dd,[LogOnTime]) <= 7 then '2013-05-01 to 2013-05-07'"
        sqlQuery += " When DATEPART(dd,[LogOnTime]) >= 8 AND DATEPART(dd,[LogOnTime]) <= 14 then '2013-05-08 to 2013-05-14'"
        sqlQuery += " When DATEPART(dd,[LogOnTime]) >= 15 AND DATEPART(dd,[LogOnTime]) <= 21 then '2013-05-15 to 2013-05-21' "
        sqlQuery += " When DATEPART(dd,[LogOnTime]) >= 22 AND DATEPART(dd,[LogOnTime]) <= 28 then '2013-05-22 to 2013-05-28'"
        sqlQuery += " End as LogOnTime "
        sqlQuery += " FROM StudentLoginHistory"
        sqlQuery += " WHERE(DatePart(mm, LogOnTime) = DatePart(mm, DateAdd(mm, -1, getdate())) AND DatePart(yyyy, LogOnTime) = DatePart(yyyy, DateAdd(mm, -1, getdate())))"
        sqlQuery += " )LT "

        sqlQuery += " GROUP BY LT.LogOnTime"

    ElseIf ddlSelectedValue = "Year" Then
        sqlQuery = "SELECT CONVERT(varchar(4),LogOnTime , 100) + CONVERT(varchar(4), LogOnTime, 120) AS duration,COUNT(*) AS posts"
        sqlQuery += " FROM StudentLoginHistory WHERE "
        sqlQuery += " year(LogOnTime) = year(DATEADD(year,-1,getdate())) "
        sqlQuery += "GROUP BY CONVERT(varchar(4),LogOnTime , 100) + CONVERT(varchar(4), LogOnTime, 120) "
        sqlQuery += "ORDER BY month(CONVERT(varchar(4),LogOnTime , 100) + CONVERT(varchar(4), LogOnTime, 120))"
    End If

    Dim ds As DataSet = objglb.getDataset(sqlQuery, "tbl")
    Dim Title As New DevExpress.XtraCharts.ChartTitle()
    Dim Diagram As XYDiagram = CType(LoginHistoryChart.Diagram, XYDiagram)
    LoginHistoryChart.Titles.Clear()
    Dim Series As New Series("Series", ViewType.Bar)
    LoginHistoryChart.Series.Add(Series)
    Series.DataSource = ds
    Series.ArgumentDataMember = "duration"
    Series.ValueScaleType = ScaleType.Numerical
    Series.ValueDataMembers.AddRange(New String() {"posts"})
    If ddlSelectedValue = "Today" Then
        Title.Text = "Login History By Today"
    ElseIf ddlSelectedValue = "Yesterday" Then
        Title.Text = "Login History By Yesterday"
    ElseIf ddlSelectedValue = "Week" Then
        Title.Text = "Login History By Last Week"
    ElseIf ddlSelectedValue = "Month" Then
        Title.Text = "Login History By Last Month"
    ElseIf ddlSelectedValue = "Year" Then
        Title.Text = "Login History By Last Year"
    End If
    'the appearance of the X-axis title.
    Diagram.AxisX.Title.Visible = True
    Diagram.AxisX.Title.Alignment = StringAlignment.Center

    If ddlSelectedValue = "Today" OrElse ddlSelectedValue = "Yesterday" Then
        Diagram.AxisX.Title.Text = "Hours"
    ElseIf ddlSelectedValue = "Week" Then
        Diagram.AxisX.Title.Text = "Days"
    ElseIf ddlSelectedValue = "Month" Then
        Diagram.AxisX.Title.Text = "Weeks"
    ElseIf ddlSelectedValue = "Year" Then
        Diagram.AxisX.Title.Text = "Months"
    End If

    Diagram.AxisX.Title.TextColor = Color.Black
    Diagram.AxisX.Title.Font = New Font("georgia", 12, FontStyle.Regular)
    Diagram.AxisX.Range.Auto = False
    'the appearance of the Y-axis title.
    Diagram.AxisY.Title.Visible = True
    Diagram.AxisY.Title.Alignment = StringAlignment.Center
    Diagram.AxisY.Title.Text = "Logins Counts"
    Diagram.AxisY.Title.TextColor = Color.Black
    Diagram.AxisY.Title.Antialiasing = True
    Diagram.AxisY.Title.Font = New Font("georgia", 10)
    CType(Series.View, SideBySideBarSeriesView).ColorEach = True
    LoginHistoryChart.Width = 900
    LoginHistoryChart.Legend.Visible = False
    LoginHistoryChart.Titles.Add(Title)
    Title.Font = New Font("georgia ", 14)

End Sub
4

1 に答える 1

0

どこにもバインドするテーブルの名前を設定しているようには見えません。私なら、変えるね

Series.DataSource = ds  

Series.DataSource = ds.Tables["tbl"]
于 2013-06-22T20:19:01.647 に答える