我不知道我到底要去哪里找。错误是:
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)
它出现在下面的代码片段中。有什么想法吗?
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在我上面发布的代码片段中。
'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
发布于 2010-09-14 04:24:24
Partial Class CaseEntry Inherits System.Web.UI.Page
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
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
发布于 2010-09-14 04:47:08
如果在getdataset之后中断并查看datatable,会发生什么?柱子在那里吗?否则,可以尝试通过列索引来访问它。
https://stackoverflow.com/questions/3703306
复制相似问题