首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >列不属于表table

列不属于表table
EN

Stack Overflow用户
提问于 2010-09-14 02:30:51
回答 2查看 4.2K关注 0票数 0

我不知道我到底要去哪里找。错误是:

代码语言:javascript
运行
复制
Column 'pkJudge' does not belong to table Table. '
   at System.Data.DataRow.GetDataColumn(String columnName)
   at System.Data.DataRow.set_Item(String columnName, Object value)
   at ReadyCollect.CaseEntry.S_GetJudges(Int32 courtID)
   at ReadyCollect.CaseEntry.S_GetExistCaseInfo()
   at ReadyCollect.CaseEntry.CaseReminder_HoldCase()
   at ReadyCollect.CaseEntry.btnSave_Click(Object sender, EventArgs e)

它出现在下面的代码片段中。有什么想法吗?

代码语言:javascript
运行
复制
Private Sub S_GetJudges(ByVal courtID As Integer)
    ' Load the list of judges   '
    Dim JudgeSet As New DataSet
    Dim dv As System.Data.DataView
    Dim DAl As New DataAccessLayer
    Dim pfkCourt As Integer = CourtDDL.SelectedValue

    If ClientKey > 0 And pfkCourt > 0 Then
        JudgeSet = DAl.GetJudgespkJudgesJudgeNamefkCourt(ClientKey, pfkCourt)
        JudgeDataTable = JudgeSet.Tables(0)
        Dim dr As System.Data.DataRow
        dr = JudgeDataTable.NewRow()
        dr("pkJudge") = "0"
        dr("Judge Name") = "(Select a Judge)"
        JudgeDataTable.Rows.Add(dr)
        JudgeDDL.SelectedValue = 0
        JudgeDDL.DataSource = JudgeDataTable.DefaultView
        dv = JudgeDataTable.DefaultView
        dv.Sort ="pkJudge ASC"
        JudgeDDL.DataBind()
    End If
End Sub

代码片段中调用的数据访问方法如下所示。现在JudgeDataTable被声明为

页面顶部的Private JudgeDataTable As System.Data.DataTable

Rest在我上面发布的代码片段中。

代码语言:javascript
运行
复制
'Retreives fields pkJudge and [Judge Name] from the table Judges where field fkCourt is equal to fkCourt '

Public Function GetJudgespkJudgesJudgeNamefkCourt(ByVal ClientKey As Integer, ByVal fkCourt As Integer) As DataSet
    Dim db As Database = DatabaseFactory.CreateDatabase()
    Dim sqlCommand As String = "USP_DISPLAYJUDGESPKJUDGEJUDGENAMEFKCOURT"
    Dim dbCommand As DbCommand = db.GetStoredProcCommand(sqlCommand)
    db.AddInParameter(dbCommand,"ClientKey", DbType.Int32, ClientKey)
    db.AddInParameter(dbCommand,"fkCourt", DbType.Int32, fkCourt)
    Return db.ExecuteDataSet(dbCommand)
End Function
EN

回答 2

Stack Overflow用户

发布于 2010-09-14 04:24:24

Partial Class CaseEntry Inherits System.Web.UI.Page

代码语言:javascript
运行
复制
     Private JudgeDataTable As System.Data.DataTable
       Private Sub S_GetJudges(ByVal courtID As Integer)

        ' Load the list of judges
        JudgeDataTable = New System.Data.DataTable
        Dim JudgeSet As New DataSet
        Dim dv As System.Data.DataView
        Dim DAl As New DataAccessLayer
        Dim pfkCourt As Integer = CourtDDL.SelectedValue
        If ClientKey > 0 And pfkCourt > 0 Then
            JudgeSet = DAl.GetJudgespkJudgesJudgeNamefkCourt(ClientKey, pfkCourt)
            JudgeDataTable = JudgeSet.Tables(0)
            Dim dr As System.Data.DataRow
            dr = JudgeDataTable.NewRow()
            dr("pkJudge") = "0"
            dr("Judge Name") = "(Select a Judge)"
            JudgeDataTable.Rows.Add(dr)
            JudgeDDL.SelectedValue = 0
            JudgeDDL.DataSource = JudgeDataTable.DefaultView
            dv = JudgeDataTable.DefaultView
            dv.Sort = "pkJudge ASC"
            JudgeDDL.DataBind()
        End If
    End Sub

'Retreives fields pkJudge and [Judge Name] from the table Judges where field fkCourt is equal to fkCourt Public Function GetJudgespkJudgesJudgeNamefkCourt(ByVal ClientKey As Integer, ByVal fkCourt As Integer) As DataSet

代码语言:javascript
运行
复制
    Dim db As Database = DatabaseFactory.CreateDatabase()
    Dim sqlCommand As String = "USP_DISPLAYJUDGESPKJUDGEJUDGENAMEFKCOURT"
    Dim dbCommand As DbCommand = db.GetStoredProcCommand(sqlCommand)

    db.AddInParameter(dbCommand, "ClientKey", DbType.Int32, ClientKey)
    db.AddInParameter(dbCommand, "fkCourt", DbType.Int32, fkCourt)

    Return db.ExecuteDataSet(dbCommand)
End Function   

票数 0
EN

Stack Overflow用户

发布于 2010-09-14 04:47:08

如果在getdataset之后中断并查看datatable,会发生什么?柱子在那里吗?否则,可以尝试通过列索引来访问它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3703306

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档