myCommand.Parameters["@LName"]
这样写: String insertCmd = "insert into Authors (au_id, au_lname) values (@Id, @LName)";
SqlCommand myCommand = new SqlCommand(insertCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@Id", SqlDbType.NVarChar, 11)); myCommand.Parameters["@Id"].Value = au_id.Value;
myCommand.Parameters.Add(new SqlParameter("@LName", SqlDbType.NVarChar, 40)); myCommand.Parameters["@LName"].Value = au_lname.Value;
比这样写:
String insertCmd = "insert into Authors (au_id, au_lname) values (au_id.Value, au_lname.Value)";
有什么好处?