-3

DateTimePickerをマスターデータファイル(.MDF)に保存しようとしています

インターネットで解決策を探してみましたが、何も見つかりませんでした。

これが私にエラーを与えているコードのセクションです:

private void cmdSave_Click(object sender, EventArgs e)
{
   dsSolomonNewTableAdapters.RegistrationTableAdapter ins = new       
     WindowsFormsApplication1.dsSolomonNewTableAdapters.RegistrationTableAdapter();
   ins.addStudent(this.dtoDOB.Value);
}

これはエラーをスローします:

System.DateTime'から'string'に変換できません

何か案は?

4

1 に答える 1

0

Based on that error message, this should fix it:

ins.addStudent(this.dtoDOB.Value.ToString());

That said, it seems like addStudent is 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 addStudent should accept a DateTime, instead of string. So in RegistrationTableAdapter, you might want to consider changing the method signature for addStudent to:

public/internal void addStudent(DateTime dob)
{
    // Do stuff
}

Again, I'm making a lot of assumptions here since you didn't post much code at all.

于 2012-09-18T18:28:37.450 に答える