我不知道我在哪裏尋找。 錯誤是:列不屬於表格表
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
在頁面頂部。
其餘部分位於我上面發佈的代碼片段中。
'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
你可以通過將代碼放在
標籤之間來格式化您的代碼嗎? – Rahul 2010-09-13 18:32:34