这段代码是更新Access数据库的,中有两个问题,让我抓狂了一天了public void UpdateExpNote(IExpNote iExpNote)
{
string SQLUpdateExpNote = "UPDATE ExpNote SET IsPublished = @IsPublished, ProgramID = @ProgramID, NoteAuthor = @NoteAuthor ,NoteName = @NoteName WHERE NoteID = @NoteID;";OleDbConnection conn = null;
conn = GetConnection();OleDbCommand cmd = new OleDbCommand(SQLUpdateExpNote, conn);cmd.Parameters.Add("@ExpNoteId", OleDbType.Integer).Value = iExpNote.ExpNoteID;
cmd.Parameters.Add("@IsPublished", OleDbType.Boolean).Value = iExpNote.IsPublished;
cmd.Parameters.Add("@NoteAuthor", OleDbType.VarWChar, 50).Value = iExpNote.ExpNoteAuthor;
cmd.Parameters.Add("@ProgramID", OleDbType.Integer).Value = iExpNote.ProgramID;
cmd.Parameters.Add("@NoteName", OleDbType.VarWChar, 100).Value = iExpNote.ExpNoteName;conn.Open();
int val = cmd.ExecuteNonQuery();
conn.Close();
}第一是不管我的iExpNote.IsPublished是true还是false,Update以后IsPublished字段的值都变成了1,(IsPublished在Access中设为 是/否 类型)第二是NoteName无论怎么样都不更新,即使别的字段都更新了它还是不变,死了不变,急死人了。有谁能帮帮我的,多谢了
{
string SQLUpdateExpNote = "UPDATE ExpNote SET IsPublished = @IsPublished, ProgramID = @ProgramID, NoteAuthor = @NoteAuthor ,NoteName = @NoteName WHERE NoteID = @NoteID;";OleDbConnection conn = null;
conn = GetConnection();OleDbCommand cmd = new OleDbCommand(SQLUpdateExpNote, conn);cmd.Parameters.Add("@ExpNoteId", OleDbType.Integer).Value = iExpNote.ExpNoteID;
cmd.Parameters.Add("@IsPublished", OleDbType.Boolean).Value = iExpNote.IsPublished;
cmd.Parameters.Add("@NoteAuthor", OleDbType.VarWChar, 50).Value = iExpNote.ExpNoteAuthor;
cmd.Parameters.Add("@ProgramID", OleDbType.Integer).Value = iExpNote.ProgramID;
cmd.Parameters.Add("@NoteName", OleDbType.VarWChar, 100).Value = iExpNote.ExpNoteName;conn.Open();
int val = cmd.ExecuteNonQuery();
conn.Close();
}第一是不管我的iExpNote.IsPublished是true还是false,Update以后IsPublished字段的值都变成了1,(IsPublished在Access中设为 是/否 类型)第二是NoteName无论怎么样都不更新,即使别的字段都更新了它还是不变,死了不变,急死人了。有谁能帮帮我的,多谢了
2、你的NoteAuthor和NoteName用的应该是一种表示方法,如果前者能更新后者不能,那绝对是人的问题了。我晕~~怎么可能哦