Column 'Date' does not belong to table Table. ? WHY ?
vb Code:
Public Sub Events_Edit()
With frmEvents
'DefineConnection(ClassName)
Adapter.UpdateCommand = New OleDbCommand("UPDATE [Events] SET [Date] = @Date, [EventName] = @EventName, [EventDesc] = @EventDesc WHERE [CIndex] = @CIndex")
With Adapter.UpdateCommand
.Connection = Connection
Connection.Open()
.Parameters.Add("@Date", OleDbType.VarChar, 150, "Date")
.Parameters.Add("@EventName", OleDbType.VarChar, 100, "EventName")
.Parameters.Add("@EventDesc", OleDbType.VarChar, 255, "EventDesc")
.Parameters.Add("@CIndex", OleDbType.Integer, 5, "CIndex")
End With
Adapter.Fill(DS)
Dim DRow As DataRow
DRow = DS.Tables(0).Rows(.CMBIndex)
CalStartRange = .monthCal.SelectionRange.Start.ToShortDateString
CalEndRange = .monthCal.SelectionRange.End.ToShortDateString
DRow.BeginEdit()
DRow("Date") = "Start: " & CalStartRange & " " & "End: " & CalEndRange
DRow("EventName") = .txtName.Text
DRow("EventDesc") = .txtDesc.Text
DRow.EndEdit()
Adapter.Update(DS)
DS.AcceptChanges()
frmOverview.lstEvents.Items.Item(.cmbEvents.SelectedIndex).Text = CalStartRange & "-" & CalEndRange & ": " & .txtName.Text
.cmbEvents.Text = .txtName.Text
Events_LoadToCombo()
Connection.Close()
End With
End Sub
ERROR:
Column 'Date' does not belong to table Table.
How do I fix this error?
Hows its being called: When I call the Edit Event, and fill in my information, I get the above error. and it highlights to:
DRow("Date") = "Start: " & CalStartRange & " " & "End: " & CalEndRange
So why am I getting this error and how can I fix it ?
Re: Column 'Date' does not belong to table Table. ? WHY ?
We can't see your SELECT statement so we can't say. Have you checked what columns your DataTable DOES contain?
Re: Column 'Date' does not belong to table Table. ? WHY ?
Ah, hold up, so do I need a Select Statment before I try & update my selected item ?
EDIT:
Yes, your right, I did need a SELECT STATMENT. Or the one I was using was only getting the Event Title, so I changed it to * and works fine now. Thanks for clarifying it.