如何执行内部联接,因为我想从另一个名为 Medication 的表中检索信息,该表的属性为 Description 而不是 Location description。我该怎么做呢?
public static void UpdateLocationDescription( int locationID, string description, SqlConnection connection, SqlTransaction transaction )
{
StringBuilder sqlString = new StringBuilder();
SqlCommand command;
sqlString.Append( "UPDATE [Location] SET " );
sqlString.Append( "description = @description " );
sqlString.Append( "WHERE locationID = @locationID " );
command = new SqlCommand( sqlString.ToString(), connection );
if( ( transaction != null ) ) command.Transaction = transaction;
command.Parameters.Add( "@locationID", SqlDbType.Int ).Value = locationID;
command.Parameters.Add( "@description", SqlDbType.VarChar ).Value = description;
int rowsAffected = command.ExecuteNonQuery();
if( !( rowsAffected == 1 ) )
{
throw new Exception( "An error has occurred while updating UpdateMedicationDispenseStatus." );
}
}