I don't know exactly where I have to look for. Error is:
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)
It occurs in the following code fragment. Any Ideas?
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
And the dataaccess method that is called in the code fragment is below.
Now JudgeDataTable
is declared as
Private JudgeDataTable As System.Data.DataTable
on top of the page.
Rest is in the code fragment as I posted above.
'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