I’m just taking over an asp.net/vb site, and I’m definitely still learning. I’m receiving the following error: BC30451: ‘ByOwner’ is not declared. It may be inaccessible due to its protection level.
I call a datasource with:
<asp:GridView ID="CaseCountByOwner" runat="server" AllowSorting="true" DataSourceID="ByOwner"
And here’s what is in the codefile:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
HitMe.AddHit(Request.UserHostAddress, Request.UserAgent, Request.Url.ToString)
Dim user As String = Request.QueryString("user")
If user.Length() = 0 Then
Return
Else
ByOwner.SelectCommand = "select " & _
"TU.login_name as Owner," & _
"( select " & _
" count(1)" & _
"from table_case TC1 with (NOLOCK) " & _
"join table_user TU1 with (NOLOCK) on TU1.objid = TC1.case_owner2user " & _
"join table_gbst_elm TGE1 with (NOLOCK) on TGE1.objid = TC1.casests2gbst_elm " & _
"where TC1.case_wip2wipbin Is Not null " & _
"and TC1.x_casetype not in ('Esc- Support','CRel - Wellness') " & _
"and TU1.login_name = TU.login_name " & _
"and TGE1.title not in ('File CR') " & _
") as AllCases," & _
"( select " & _
"count(1)" & _
"from table_case TC2 with (NOLOCK) " & _
"join table_user TU2 with (NOLOCK) on TU2.objid = TC2.case_owner2user " & _
"join table_gbst_elm TGE2 with (NOLOCK) on TGE2.objid = TC2.casests2gbst_elm " & _
"where TC2.case_wip2wipbin Is Not null " & _
"and TC2.x_casetype not in ('Esc- Support','CRel - Wellness') " & _
"and TGE2.title not in ('File CR','Suggested Resolution','Suggestion Filed','Await SW Rel/Dev','Pending ClientAction') " & _
"and TU2.login_name = TU.login_name" & _
") as Workable," & _
"( select " & _
"count(1)" & _
"from table_case TC3 with (NOLOCK) " & _
"join table_user TU3 with (NOLOCK) on TU3.objid = TC3.case_owner2user " & _
"join table_gbst_elm TGE3 with (NOLOCK) on TGE3.objid = TC3.casests2gbst_elm " & _
"join table_gbst_elm SEVERITY3 with (NOLOCK) on TC3.respsvrty2gbst_elm = SEVERITY3.objid " & _
"where TC3.case_wip2wipbin Is Not null " & _
"and TC3.x_casetype not in ('Esc- Support','CRel - Wellness') " & _
"and SEVERITY3.title in ('Down','Critical - ANF') " & _
"and TGE3.title not in ('File CR','Suggestion Filed','Await SW Rel/Dev','Pending ClientAction') " & _
"and TU3.login_name = TU.login_name" & _
") as DownCritical, " & _
"( select " & _
"count(1)" & _
"from table_case TC4 with (NOLOCK) " & _
"join table_user TU4 with (NOLOCK) on TU4.objid = TC4.case_owner2user " & _
"join table_gbst_elm TGE4 with (NOLOCK) on TGE4.objid = TC4.casests2gbst_elm " & _
"where TC4.case_wip2wipbin Is Not null " & _
"and TC4.x_casetype not in ('Esc- Support','CRel - Wellness') " & _
"and TGE4.title in ('Testing Data') " & _
"and TU4.login_name = TU.login_name" & _
") as TestingData " & _
"from table_user TU with (NOLOCK)" & _
"where TU.login_name in (select TU.login_name from table_employee TE with (NOLOCK) " & _
"join table_user TU with (NOLOCK) on TE.employee2user = TU.objid and TU.status = 1 " & _
"where TE.emp_supvr2employee = (select EMPTE.emp_supvr2employee " & _
"from table_user EMPTU with (NOLOCK) " & _
"join table_employee EMPTE with (NOLOCK) on EMPTE.employee2user = EMPTU.objid " & _
"where EMPTU.login_name like ('" & user & "') " & _
")) " & _
"order by 1 "
End If
End Sub
Dim casesTotal As Integer = 0
Dim workableTotal As Integer = 0
Dim downTotal As Integer = 0
Dim testingTotal As Integer = 0
Protected Sub CaseCountByOwner_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
casesTotal += (DataBinder.Eval(e.Row.DataItem, "AllCases"))
workableTotal += (DataBinder.Eval(e.Row.DataItem, "Workable"))
downTotal += (DataBinder.Eval(e.Row.DataItem, "DownCritical"))
testingTotal += (DataBinder.Eval(e.Row.DataItem, "TestingData"))
ElseIf e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(0).Text = "Totals:"
e.Row.Cells(1).Text = casesTotal
e.Row.Cells(2).Text = workableTotal
e.Row.Cells(3).Text = downTotal
e.Row.Cells(4).Text = testingTotal
e.Row.Font.Bold = True
End If
End Sub
Protected Sub UpdateTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
LiveQueue.DataBind()
LabelLiveQueue.Text = "Updated: " + DateAndTime.Now.ToString()
End Sub
Protected Sub UpdateTimer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
LiveAgents.DataBind()
LabelLiveAgents.Text = "Updated: " + DateAndTime.Now.ToString()
End Sub
Dim callsTotal As Integer = 0
Dim offeredTotal As Integer = 0
Dim handledTotal As Integer = 0
Protected Sub LiveQueueGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
callsTotal += (DataBinder.Eval(e.Row.DataItem, "Holding"))
offeredTotal += (DataBinder.Eval(e.Row.DataItem, "Offered"))
handledTotal += (DataBinder.Eval(e.Row.DataItem, "Handled"))
ElseIf e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(0).Text = "Totals:"
e.Row.Cells(1).Text = callsTotal
e.Row.Cells(3).Text = offeredTotal
e.Row.Cells(4).Text = handledTotal
e.Row.Font.Bold = True
End If
End Sub
Dim TotalCalls As Int32 = 0
Function GetCalls(ByVal Calls As Int32) As Int32
TotalCalls += Calls
Return Calls
End Function
Function GetTotal() As Int32
Return TotalCalls
End Function
Protected Sub BtnExportGrid_Click(ByVal sender As Object, ByVal args As EventArgs)
' pass the grid that for exporting ...
Me.CaseView.GridLines = GridLines.Both
GridViewExportUtil.Export("Cases.xls", Me.CaseView)
End Sub
End Class
Any help is greatly appreciated, and even more appreciated would be a link to a good resource on getting started with .net applications.
You need to have a a
SqlDataSourcesomewhere in your page with ID “ByOwner”For example:
Notice that you are declaring your datasource of the GridView to be “ByOwner”.