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,
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?
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
Re: DateTimePicker Database problem
Re: DateTimePicker Database problem