I’m trying to save my DateTimePicker in my Master Data File (.MDF)
I tried searching the Internet for a solution but haven’t been able to find anything.
Here is the section of code that is giving me the error:
private void cmdSave_Click(object sender, EventArgs e)
{
dsSolomonNewTableAdapters.RegistrationTableAdapter ins = new
WindowsFormsApplication1.dsSolomonNewTableAdapters.RegistrationTableAdapter();
ins.addStudent(this.dtoDOB.Value);
}
This throws an error:
Cannot convert from System.DateTime’ to ‘string’
Any ideas?
Based on that error message, this should fix it:
That said, it seems like
addStudentis adding a DOB, not a student. Since I only have the code you posted to work with, I went with the.ToString().Edit: After seeing your last comment, it looks like
addStudentshould accept aDateTime, instead ofstring. So inRegistrationTableAdapter, you might want to consider changing the method signature foraddStudentto:Again, I’m making a lot of assumptions here since you didn’t post much code at all.