Results 1 to 5 of 5

Thread: DateTimePicker Database problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Angry DateTimePicker Database problem

    Hello,

    I am having a tough time debugging a code. I would appreciate some help.

    In my form, I have a DateTimePicker that is connected to a database. I entered a date manually in the database and when I load the form, it reads the date and displays it just fine. However, when I pick a date in the datepicker, and update the database, the following error comes up and the operation fails:

    Code:
    The column name is not valid. [ Node name (if any) = ,Column name = DateTimePickerMembershipExpiration ]
    In the table schema, the data type for that field was date and failed to convert. I made it nvarchar and that error pops up. Not sure what the problem is since it reads it on form load so it DOES exist.

    Any ideas?

    Best,
    Kalogerus Productions (K-Pro)

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

    Re: DateTimePicker Database problem

    Why would you have a database column name that contained "DateTimePicker"? The type of control used in the UI to display and edit that data is completely irrelevant to the database. It would appear that the appropriate name for that column would be "MembershipExpirationDate" and the data type absolutely should be 'date' or 'datetime' or whatever's similar in the database you're using.

    Controls are not connected to databases. Controls can be bound to local lists. You probably have it bound to a DataTable. That DataTable may be based on the schema of the database but it is not the database.

    What property of the DateTimePicker did you bind to? Was it Text or Value? Can that column accept NULL values? If so then you can't bind to a DateTimePicker because it doesn't support binding to nullable data. What are the database table and column names? What are the DataTable and DataColumn Names? What is the DateTimePicker data-binding expression?
    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
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Re: DateTimePicker Database problem

    Whoa brain-freeze I guess. I just realized the name didn't exist for a reason. I suspected something but didn't quite catch it. Thank you for pointing it out.

    Best
    Kalogerus Productions (K-Pro)

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Re: DateTimePicker Database problem

    Thank you
    Last edited by K-PRO; Oct 7th, 2013 at 11:35 PM.
    Kalogerus Productions (K-Pro)

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

    Re: DateTimePicker Database problem

    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

Tags for this Thread

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