代码的一个问题
private OleDbConnection cnn = null;private OleDbCommand cmm = null;
private OleDbDataAdapter sda = null;
private OleDbParameter sp = null;
private DataSet ds = null;
public frmStu()
private void btnAdd_Click(object sender, EventArgs e)
{
cmm = new OleDbCommand("INSERT INTO stu VALUES(@stuNo,@stuName,@stuScore)",cnn);
sda = new OleDbDataAdapter();
sda.InsertCommand = cmm;
sp = sda.InsertCommand.Parameters.Add("@stuNo", null);
sp.SourceColumn = "stuNo";
sp.SourceVersion = DataRowVersion.Current;
sp = sda.InsertCommand.Parameters.Add("@stuName", null);
sp.SourceColumn = "stuName";
sp.SourceVersion = DataRowVersion.Current;
sp = sda.InsertCommand.Parameters.Add("@stuScore", null);
sp.SourceColumn = "stuScore";
sp.SourceVersion = DataRowVersion.Current;
sda.Update(ds, "stu");
}
private void btnUpdate_Click(object sender, EventArgs e)
{
cmm = new OleDbCommand("UPDATE stu SET stuName = @stuName,stuScore = @stuScore WHERE stuNo = @stuNo", cnn);
sda = new OleDbDataAdapter();
sda.UpdateCommand = cmm;
sp = sda.UpdateCommand.Parameters.Add("@stuNo", null);
sp.SourceColumn = "stuNo";
sp.SourceVersion = DataRowVersion.Original;
sp = sda.UpdateCommand.Parameters.Add("@stuName", null);
sp.SourceColumn = "stuName";
sp.SourceVersion = DataRowVersion.Current;
sp = sda.UpdateCommand.Parameters.Add("@stuScore", null);
sp.SourceColumn = "stuScore";
sp.SourceVersion = DataRowVersion.Current;
sda.Update(ds, "stu");
}
这是guoxhvip给我发的程序上的代码 可我用的是ACCESS 改了自己会改的 但之后就出现错误了
谁知道我哪里出现错误了?