Results 1 to 3 of 3

Thread: Column 'Date' does not belong to table Table. ? WHY ?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    258

    Column 'Date' does not belong to table Table. ? WHY ?

    vb Code:
    1. Public Sub Events_Edit()
    2.         With frmEvents
    3.             'DefineConnection(ClassName)
    4.             Adapter.UpdateCommand = New OleDbCommand("UPDATE [Events] SET [Date] = @Date, [EventName] = @EventName, [EventDesc] = @EventDesc WHERE [CIndex] = @CIndex")
    5.             With Adapter.UpdateCommand
    6.                 .Connection = Connection
    7.                 Connection.Open()
    8.                 .Parameters.Add("@Date", OleDbType.VarChar, 150, "Date")
    9.                 .Parameters.Add("@EventName", OleDbType.VarChar, 100, "EventName")
    10.                 .Parameters.Add("@EventDesc", OleDbType.VarChar, 255, "EventDesc")
    11.                 .Parameters.Add("@CIndex", OleDbType.Integer, 5, "CIndex")
    12.             End With
    13.             Adapter.Fill(DS)
    14.             Dim DRow As DataRow
    15.             DRow = DS.Tables(0).Rows(.CMBIndex)
    16.             CalStartRange = .monthCal.SelectionRange.Start.ToShortDateString
    17.             CalEndRange = .monthCal.SelectionRange.End.ToShortDateString
    18.             DRow.BeginEdit()
    19.             DRow("Date") = "Start: " & CalStartRange & " " & "End: " & CalEndRange
    20.             DRow("EventName") = .txtName.Text
    21.             DRow("EventDesc") = .txtDesc.Text
    22.             DRow.EndEdit()
    23.             Adapter.Update(DS)
    24.             DS.AcceptChanges()
    25.             frmOverview.lstEvents.Items.Item(.cmbEvents.SelectedIndex).Text = CalStartRange & "-" & CalEndRange & ": " & .txtName.Text
    26.             .cmbEvents.Text = .txtName.Text
    27.             Events_LoadToCombo()
    28.             Connection.Close()
    29.         End With
    30.     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 ?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    258

    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.
    Last edited by Wesley008; Nov 4th, 2008 at 07:23 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width