我是C#中使用Access数据库的新手,想知道是否可以替换此代码
string sql = "UPDATE Volunteer SET
VolunteerName = @VolunteerName,
NickName = @NickName,
ContactNo = @ContactNo
WHERE VolunteerID = @VolunteerID ";
dbCmd = new OleDbCommand(sql, dbConn);
dbCmd.Parameters.AddWithValue("@VolunteerName", txtLastName.Text);
dbCmd.Parameters.AddWithValue("@NickName", txtFirstName.Text);
dbCmd.Parameters.AddWithValue("@ContactNo", txtContact.Text);
dbCmd.Parameters.AddWithValue("@VolunteerID", txtVolunteerID.Text);
与此类似的东西
string sql = "UPDATE Volunteer SET
VolunteerName = "+ txtLastName.Text +",
NickName = "+ txtFirstName.Text +",
ContactNo = "+ txtContact.Text +"
WHERE VolunteerID = "+ txtVolunteerID.Text ";
dbCmd = new OleDbCommand(sql, dbConn);